Google分析电子商务无法正常运作

时间:2016-05-27 13:21:20

标签: javascript google-analytics enhanced-ecommerce

这是我的代码:

(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','https://www.google-analytics.com/analytics.js','ga');

  ga('create', 'UA-xxxxxx-1', 'auto');

  ga('require', 'ecommerce');
  ga('ecommerce:addTransaction', {
    'id': '22287', // Transaction ID. Required.
    'affiliation': 'GBA', // store name.
    'revenue': '0.00', // total revenue.
    'shipping': '0.00', // Shipping.
    'tax': '0.0' // Tax.
   });

   ga('ecommerce:addItem', {
     'id': '22287', // Transaction ID. Required. Same as in the transaction data.
     'name': 'GBA', // Product name. Required.
     'sku': 'product123', // Product SKU.
     'category': '', // Product Category or variation.
     'price': '1.50', // Product price.
     'quantity': '1' // Product Quantity.
   });

   ga('ecommerce:send');
   ga('send', 'pageview');

这不会跟踪电子商务中的任何内容,我的Google分析帐户启用了电子商务。

0 个答案:

没有答案