我已经为我正在开发的网站启用了电子商务。我想不明白。以下是我感谢页面末尾的片段:
(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');
更新
感谢 yahelc 编辑我的代码。我发现我必须为客户网站打开通用。但客户已经在使用旧的谷歌分析,我不知道如何同时打开.....ga.js和analytics.js............