Google Analytics电子商务跟踪无法正常运行

时间:2014-03-01 11:06:20

标签: javascript google-analytics

下面提供了代码。我把它包含在感谢页面中。

##ITEM# - these are the replace codes and they are working just fine.

问题是什么?

<!-- GOOGLE ANALYTICS ECOMMERCE CONVERSION TRACKING -->
<!-- https://developers.google.com/analytics/devguides/collection/analyticsjs/ecommerce -->

<script>

ga('require', 'ecommerce', 'ecommerce.js');

ga('ecommerce:addTransaction', {
  'id': ##ORDER_ID#,                     // Transaction ID. Required.
  'revenue': ##ORDER_PRICE#,               // Grand Total.
  'tax': ##ORDER_PRICE_TAX#                     // Tax.
});

ga('ecommerce:send');

</script>
<!-- END: GOOGLE ANALYTICS CONVERSION TRACKING -->

2 个答案:

答案 0 :(得分:4)

我已经在我的项目中集成了ecommnerce代码,它对我来说很好。下面我添加了代码。

 <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-XXXX-Y', 'auto');
ga('send', 'pageview');
ga('require', 'ecommerce', 'ecommerce.js');   // Load the ecommerce plug-in.

ga('ecommerce:addTransaction', {
  'id': '1234',                     // Transaction ID. Required
  'affiliation': 'Acme Clothing',   // Affiliation or store name
  'revenue': '11.99',               // Grand Total
  'shipping': '5',                  // Shipping
  'tax': '1.29'                     // Tax
});

// addItem should be called for every item in the shopping cart.
ga('ecommerce:addItem', {
  'id': '1234',                     // Transaction ID. Required
  'name': 'T-Shirt',                // Product name. Required
  'sku': 'DD44',       // SKU/code
  'category': 'Green Medium',       // Category or variation
  'price': '11.99',                 // Unit price
  'quantity': '1'                   // Quantity
});

</script>

请详细阅读指定链接:ecommerce tracking code

快乐编码..: - )

答案 1 :(得分:1)

您必须激活GA - 电子商务选项。

GA:      管理员 - &gt;电子商务设置 - &gt;启用电子商务 - &gt;状态:开启