Google Analytics does not track transactions.

I'm having trouble getting Google Analytics to track transactions for trading. Here is the code that I create on the order confirmation page.

I donโ€™t know how to debug this either, I canโ€™t find information on how to get error codes from google js. I would run it in the firebug console if I could. At this moment, I was fixated on how to act.

<script type="text/javascript">
    var _gaq = _gaq || [];
    _gaq.push(['_setAccount', 'UA-########-#']);
    _gaq.push(['_setDomainName', '.mydomain.com']);
    _gaq.push(['_trackPageview']);


    _gaq.push(['_addTrans',
      '117',           // order ID - required
      'StoreName.com',  // affiliation or store name
      '35.96',          // total - required
      '0',           // tax
      '0',              // shipping
      '',       // city
      '',     // state or province
      ''             // country
    ]);
    _gaq.push(['_addItem',
      '117',           // order ID - required
      '1',           // SKU/code - required
      '1 Pack',        // product name
      'Catagory5',          // catagory   
      '35.96,          // unit price - required
      '1'               // quantity - required
    ]);
    _gaq.push(['_trackTrans']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(ga);
  })();
</script>

Thanks for any suggestions.

+3
source share
1 answer

Checkout this page in Google Code. This is an example of what you are trying to do.

+3
source

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


All Articles