Google Universal电子商务跟踪

时间:2014-04-24 17:20:30

标签: javascript google-analytics

我这样做了吗?我只是使用已有数据的示例。

不确定这是否是正确的方法,因为我的测试订单都没有登陆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--1', 'amleo.com');ga('send', 'pageview');
//Include the ecommerce plugin
ga('require', 'ecommerce', 'ecommerce.js');
//Initialize the transaction
ga('ecommerce:addTransaction', {
    'id': 'WEBA001399736',// order ID - required      
    'affiliation': 'A.M. Leonard',// affiliation or store name      
    'revenue': '19.99',// total - required
    'shipping': '9.99',// shipping     
    'tax': '2.10',// tax
});

ga('ecommerce:addItem', {
    'id': 'WEBA001399736',// order ID - necessary to associate item with transaction      
    'name': 'Leonard+ArborRain+Tower+-+Plant+%26+Tree+Hydrator',// product name 
    'sku': 'ART20',// SKU/code - required     
    'category': '',// category or variation      
    'price': '19.99',// unit price - required      
    'quantity': '1'// quantity - required   
});

ga('ecommerce:send');//submits transaction to the analytics servers
</script>

0 个答案:

没有答案