【发布时间】:2016-03-18 23:19:26
【问题描述】:
我需要您在 Google Analytics (analytics.js) 方面的帮助。我在头部有第一个通用部分,效果很好:
<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-72717911-1', 'auto');
ga('send', 'pageview');
</script>
但是,当我将以下部分添加到“成功”页面的常规正文部分以跟踪交易时,我在谷歌分析中没有收到它。我根本不是 JS 专家,所以解决方案可能很简单,但是我在调试工具中看不到任何错误,甚至 chrome 的特殊谷歌插件看起来也很正常。
<script>
ga('require', 'ecommerce');
ga('ecommerce:addTransaction', {
'id': '001', // Transaction ID. Required.
'affiliation': 'trendybox.com.ua', // Affiliation or store name.
'revenue': '500', // Grand Total.
'shipping': '0', // Shipping.
'tax': '0' // Tax.
});
ga('ecommerce:addItem', {
'id': '" . $order_id . "', // Transaction ID. Required.
'name': 'product1', // Product name. Required.
'sku': 'DD00111', // SKU/code.
'category': 'Cosmetics', // Category or variation.
'price': '500', // Unit price.
'quantity': '1' // Quantity.
});
ga('ecommerce:send');
</script>"
【问题讨论】:
-
在 GA 的设置下是“启用电子商务”是否开启?
-
根据我对 nyuens 回答的评论,还要检查“增强型电子商务设置”是否已关闭,因为标准跟踪代码不适用于启用 EEC。
-
嗨@EikePierstorff,我相信即使在设置中启用了EE,标准电子商务仍然可以工作。在我的回答中,我捕获了我的设置,但(部分)交易详情仍然出现在我的报告中。
标签: google-analytics analytics.js