我正在尝试使用Google标签管理器设置电子商务跟踪,但是我无法将数据显示在Google Analytics(分析)中?
https://support.google.com/tagmanager/answer/6107169?hl= en
使用上面链接上提供的示例,这是我的代码:
<html>
<head>
<script>
window.dataLayer = window.dataLayer || [];
dataLayer.push({
'transactionId': '1238393768',
'transactionAffiliation': 'Website Name',
'transactionTotal': 105.78,
'transactionTax': 21.156,
'transactionShipping': 18.00,
'transactionProducts': [
{
'sku': '97',
'name': 'Test Product 1',
'category': 'Test Category One, Test Category Two',
'price': 13.99,
'quantity': 24
},
{
'sku': '97',
'name': 'Test Product 2',
'category': 'Test Category One, Test Category Two',
'price': 3.99,
'quantity': 22
},
]
});
</script>
<!-- Google Tag Manager -->
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-CODE');</script>
<!-- End Google Tag Manager -->
</head>
<body>
<!-- Google Tag Manager (noscript) -->
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-CODE"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
</body>
</html>
任何人都可以建议为什么这不起作用,以及如何将数据显示在Google Analytics(分析)中?
我不明白的一件事是如何/在哪里知道将数据添加到我的分析帐户中?我需要做其他事情或GTM或GA中需要的任何配置吗?
谢谢。
您无法在标签管理器的脚本之前推开。它应该是变量的初始化。喜欢:
<script>
dataLayer = [{
'pageCategory': 'signup',
'visitorType': 'high-value'
}];
</script>
编辑:文档https://developers.google.com/tag-manager/devguide