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. 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..........
您可以同时运行ga.js和analytics.js,但是您需要先将GA配置文件创建为通用Analytics(分析)配置文件(创建后无法对其进行更新)。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.