我已经多次使用以前版本的分析来设置电子商务跟踪,但没有让新的通用分析版本正常工作。
到目前为止,我在收据页面上有这个(当我运行测试交易时,所有变量都正确填充,我只是在下面的示例中放入了占位符变量),但似乎没有为交易触发像素:
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-########-#', 'secure.example.com');
ga('require', 'ecommerce', 'ecommerce.js');
ga('send', 'pageview');
ga('ecommerce:addTransaction', {
'id': '[id]',
'affiliation': '[storename]',
'revenue':'[total]',
'shipping':'[shipping]',
'tax': '[tax]'
});
#foreach ($item in $order.getItems())
ga('ecommerce:addItem', {
'id': '[id]',
'name': '[product]',
'sku': '[sku]',
'category': '',
'price': '[unitprice]',
'quantity': '[quantity]'
});
#end
ga('ecommerce:send');
</script>
在以前的分析版本中,触发综合浏览量首先对我有用;这是为通用分析片段构建此结构的错误方法吗?