[英]How to test and implement data layer in Google Tag Manager for Google Analytics
We are using enhanced eCommerce tracking by using data layer, to setup and test it in local environment.我们通过使用数据层使用增强的电子商务跟踪,在本地环境中设置和测试它。 We can see page views in analytics but the event and impressions are not triggered.
我们可以在分析中看到页面浏览量,但不会触发事件和印象。 I tried using this:
我尝试使用这个:
dataLayer.push({
'ecommerce': { 'Impression': [ { 'name': '${product.name}' ,'id': '${product.code}' }]}
});
dataLayer.push({
'ecommerce':
{ 'detail':
{ 'products':
[{
'name': '${product.name}',
'id': '${product.code}',
'variant': '${product.style}'
}]
}
}
});
But I don't know how to test in local.但是我不知道如何在本地进行测试。 I have tested using Google tag manager Debug mode, but it shows datalayer has been pushed but I can't track that event in Google Analytics
我已经使用 Google 标签管理器调试模式进行了测试,但它显示数据层已被推送,但我无法在 Google Analytics 中跟踪该事件
At least for the impressions, it looks like you are not using the correct parameter name (you have "Impression", but it should be "impressions").至少对于印象,看起来您没有使用正确的参数名称(您有“印象”,但应该是“印象”)。 Impressions should be measured as such, taken from this guide, https://developers.google.com/tag-manager/enhanced-ecommerce :
应如此衡量展示次数,取自本指南https://developers.google.com/tag-manager/enhanced-ecommerce :
// Product impressions are sent by pushing an impressions object
// containing one or more impressionFieldObjects.
dataLayer.push({
'ecommerce': {
'currencyCode': 'EUR', // Local currency is optional.
'impressions': [
{
'name': 'Triblend Android T-Shirt', // Name or ID is required.
'id': '12345',
'price': '15.25',
'brand': 'Google',
'category': 'Apparel',
'variant': 'Gray',
'list': 'Search Results',
'position': 1
}]
}
});
I have recently implemented this for a client and found that omnibug (for firefox or chome) and google real-time reports were the best combination for testing once we'd set everything up.我最近为一个客户实现了这个,发现一旦我们设置了一切,omnibug(用于 firefox 或 chome)和谷歌实时报告是测试的最佳组合。
I pretty much went by the book having my developer setup the datalayer (very important that this be above the GTM tag in your code!) and setting up the various macros, rules, and tags myself in GTM according to this documentation (different from your link): https://developers.google.com/tag-manager/enhanced-ecommerce It's easy to miss the collapsed tag manager configuration steps on that page.我几乎按照这本书让我的开发人员设置数据层(非常重要的是,它位于代码中的 GTM 标记之上!)并根据此文档(与您的不同)在 GTM 中自己设置各种宏、规则和标记链接): https : //developers.google.com/tag-manager/enhanced-ecommerce很容易错过该页面上的折叠标签管理器配置步骤。 I know I did.
我知道我做到了。
If you've implemented all of the GTM settings, then most of the enhanced ecommerce stuff should show up in omnibug when you initiate any of the actions that should trigger those events.如果您已实施所有 GTM 设置,那么当您启动任何应触发这些事件的操作时,大多数增强型电子商务内容都应显示在 omnibug 中。
The piece we had the most difficult time with was product impressions as our product listing pages are ajax driven.我们遇到的最困难的部分是产品印象,因为我们的产品列表页面是由 ajax 驱动的。
I also found Simo Hava's blog post on this very helpful!我还发现 Simo Hava 的博客文章对此非常有帮助! http://www.simoahava.com/analytics/ecommerce-tips-google-tag-manager/
http://www.simoahava.com/analytics/ecommerce-tips-google-tag-manager/
Note: For the record with our setup we use a separate container for production and development environments which is what enables us to publish and test out with omnibug.注意:为了记录我们的设置,我们为生产和开发环境使用了一个单独的容器,这使我们能够使用 omnibug 发布和测试。 I find Simo's GTM Tools very useful for this too so I can just copy over select tags, macros, and rules: http://www.simoahava.com/analytics/introducing-gtm-tools/
我发现 Simo 的 GTM 工具对此也非常有用,因此我可以复制选择的标签、宏和规则: http : //www.simoahava.com/analytics/introducing-gtm-tools/
Good luck!祝你好运!
In localhost used to check tracking by Google Tag Assistant在 localhost 中用于检查 Google Tag Assistant 的跟踪
https://chrome.google.com/webstore/detail/tag-assistant-by-google/kejbdjndbnbjgmefkgdddjlbokphdefk https://chrome.google.com/webstore/detail/tag-assistant-by-google/kejbdjndbnbjgmefkgdddjlbokphdefk
I think it is best way to check datalayer我认为这是检查数据层的最佳方法
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.