简体   繁体   中英

Google analytics ecommerce not tracking

I am trying to implement ecommerce tracking for a site i am working on but running into some problems. I have read the docs, debugged with the plugin for chrome, but I just can't seem to get it working.

This is the test code I have written (this will eventually be generated by PHP which isn't a problem):

<script type="text/javascript">
(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-XXXXXXXX-X', 'auto');
ga('require', 'ecommerce', 'ecommerce.js');
ga('require', 'linkid', 'linkid.js');
ga('require', 'displayfeatures');
ga('send', 'pageview');
<?php
    //log product details view
    echo "ga('ecommerce:addTransaction', {
      'id': 'P129945',
      'affiliation': 'test item',
      'revenue': '10.00',
      'shipping': '5.00',
      'tax': '1.00'
    });";

    echo "ga('ecommerce:addItem', {
      'id': 'P129945',
      'name': 'test item',
      'category': 'Apparel',
      'brand': 'abc',
      'variant': 'red'
    });";

    echo "ga('ecommerce:send');";

?>          
</script>

The analytics debugging tool shows all the transaction & item information and everything looks to be working, however nothing shows up in analytics. Other events are registered as normal. I also tried using the new enhanced ecommerce suite & commands but ran into the same problem.

Any help with this would be greatly appreciated!

Are you sure that ecommerce is enabled in the viewsettings? It's disabled by default.

Make sure you're using the 'raw' view. (Admin -> View -> RAW (from select field)).

There might be some filters applied, like IP exclusion (hides all transactions made from certain ip). There shouldn't be anything here by default, but if someone else was managing analytics before you, there might be.

Also, it may take up to 24 hours for the data to appear.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM