javascript - Google Analytics 电子商务跟踪不起作用

标签 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 -->

最佳答案

我在我的项目中集成了 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

快乐编码.. :-)

关于javascript - Google Analytics 电子商务跟踪不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22113530/

相关文章:

Javascript 窘境 : Creating a highlighter pen tool. .. 差不多了

javascript 类 ID 在对象创建时计数

ios - 适用于 iOS 的 Google Analytics SDK 3.0 : Anonymize IPs

google-analytics - 如何在Blogger博客中添加Google Analytics(分析)?

google-analytics - 谷歌分析臃肿的数据

javascript - Sequelize.Model 的 VsCode 智能感知问题

javascript - HTML5 样板 plugins.js

javascript - 创建指令时不显示背景图像

heroku - heroku 上的谷歌分析。如何让它同时跟踪 <APPNAME>.herokuapp.com 和 <APPNAME>.com

javascript - 同步通用分析