简体   繁体   中英

Google Analytics E-commerce Tracking Issue

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>

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.

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