[英]What is wrong with my e-commerce tracking with the new API?
I have already enabled e-commerce for the website i am working on. 我已经为正在工作的网站启用了电子商务。 I cannot figure it out. 我想不明白。 The following is the snippet at the end of my thank you page: 以下是“谢谢”页面末尾的片段:
(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-HIDE_ME');
ga('require', 'ecommerce', 'ecommerce.js');
ga('send', 'pageview');
ga('set', 'currencyCode', 'EUR');
ga('ecommerce:addTransaction', {
'id': '64807', // Transaction ID. Required.
'affiliation': 'my company',// Affiliation or store name.
'revenue': '117,00',// Grand Total.
'shipping': '0', // Shipping.
'tax': '0'// Tax.
});
ga('ecommerce:addItem', {
'id': '64807',// Transaction ID. Required.
'name': 'Sleeping Beauty Musical 1', // Product name. Required.
'sku': 'Sleeping Beauty', // SKU/code.
'category': 'muziektheater', // Category or variation.
'price': '19,00', // Unit price.
'quantity': '1'// Quantity.
});
ga('ecommerce:addItem', {
'id': '64807', // Transaction ID. Required.
'name': 'Sleeping Beauty Musical 2', // Product name. Required.
'sku': 'Sleeping Beauty', // SKU/code.
'category': 'muziektheater',// Category or variation.
'price': '16,00',// Unit price.
'quantity': '1' // Quantity.
});
ga('ecommerce:addItem', {
'id': '64807', // Transaction ID. Required.
'name': 'The Lion King Musical', // Product name. Required.
'sku': 'Lion King', // SKU/code.
'category': 'dans', // Category or variation.
'price': '41,00', // Unit price.
'quantity': '2' // Quantity.
});
ga('ecommerce:send');
thanks yahelc for editing my code. 谢谢yahelc编辑我的代码。 I found that i have to turn on universal for the clients website. 我发现我必须为客户网站打开通用功能。 but the client is already using the old google analytics and i am not sure how to turn on both.....ga.js and analytics.js.......... 但是客户端已经在使用旧的Google Analytics(分析),而且我不确定如何同时打开..... ga.js和analytics.js ..........
您可以同时运行ga.js和analytics.js,但是您需要先将GA配置文件创建为通用Analytics(分析)配置文件(创建后无法对其进行更新)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.