views:

164

answers:

1

I have ecommerce tracking set up on my site and in google analytics. The problem is that sometimes it tracks the e-commerce sales but sometimes it doesn't.

Here is the code which is being output before my closing body tag:

<!-- BEGIN GOOGLE ANALYTICS CODE -->
<script type="text/javascript">
//<![CDATA[
    var _gaq = _gaq || [];
    _gaq.push(["_setAccount", "UA-2795368-10"]);
    _gaq.push(["_trackPageview", "/checkout/onepage/success/"]);

    (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>
<!-- END GOOGLE ANALYTICS CODE -->
        <script type="text/javascript">
//<![CDATA[
_gaq.push(["_addTrans","100000029","","10.0000","0.0000","0.0000","asa","","GB"]);
_gaq.push(["_addItem","100000029","12","Test Item","","10.0000","1.0000"]);
_gaq.push(["_trackTrans"]);
//]]></script></div>
+1  A: 

One of the advantages of async Google Analytics is that you can put it at the top of the page.
Google recommends putting it at the top of the body, not the bottom. Your intermittent tracking may be due to people leaving the page before the tracking beacon has been sent. This could be fixed by putting the code higher in the page.

http://code.google.com/apis/analytics/docs/tracking/asyncTracking.html#Installation

Your code looks good otherwise. It would be help if you posted the live URL though.

Brian