Google Tag Assistant 在使用 Universal Analytics 跟踪交易时报告了 2 个严重错误:
错误:未知方法名称:“addTransaction”
错误:方法“发送”缺少 1 个必需参数。
该交易在 Google Analytics 中报告,但我担心这个错误。这是我的报告代码:
<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-XXXXXXXX-1', {
'clientId': 'XXX'
});
ga('require', 'ecommerce', 'ecommerce.js');
ga('ecommerce:addTransaction', {
'id': '5',
'affiliation': 'xxx',
'revenue': '0', // revenue is 0 because discount coupon was applied
'shipping': '15',
'currency': 'CHF'
});
ga('ecommerce:addItem', {
'id': '5',
'name': 'XXX',
'sku': '3387',
'price': '35.80',
'quantity': '1'
});
ga('ecommerce:send');
ga('send', 'pageview');
</script>
在 Google 产品论坛中,用户 Whims 建议使用
ga('send', 'ecommerce');
请参阅:http ://productforums.google.com/d/msg/analytics/L6bWIxPtNbA/PKUJLCfz6qsJ但开发人员文档中没有这样的内容。