Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Analytics not tracking transactions

I'm having trouble getting Google Analytics to track transactions for commerce. Here's the code I'm generating on my order confirmation page.

I don't know how to debug this either, I can't find information on how to get error codes out of google's js. I'd run it in firebug's console if I could. At this point I'm stuck on how to proceed.

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

Thank you for any suggestions.

like image 236
reconbot Avatar asked May 24 '26 14:05

reconbot


1 Answers

Checkout this page on Google Code. It provides an example of what your trying to do.

like image 147
Binary Nerd Avatar answered May 27 '26 02:05

Binary Nerd



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!