Google Analytics Ecommerce Tracking Not Tracked

The code is below. I include it on the thank you page.

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

What is the problem?

<!-- 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 -->
+4
source share
2 answers

I have ecommnerce inline code in my project and it works great for me. I have added the code below.

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

Please follow this link for more details: e-commerce tracking code

Happy coding .. :-)

+4
source

You must activate the GA - ecommerce option.

GA: Admin → Ecommerce Settings → Enable Ecommerce → Status: ON

+1
source

Source: https://habr.com/ru/post/1529540/


All Articles