• Hello,

    I am trying to insert ecommerce tracking on a page on my website using ecommerce tracking from google analytics. The purchases are working fine, but I don’t see the sales in my Google analytics ecommmerce report ??

    I downloaded “NK Google Analytics” plugin for general GA tracking, and I added the code I found on sitepoint website (https://www.sitepoint.com/track-ecommerce-transactions-google-analytics-reports/) to my page only in the case the transaction is successfull. For now, I put it only on a test website, as it’s not working yet.

    I am far from being a Javascript expert, and so far could not figure out whatis going wrong… Here are the parts related to GA:

    <!DOCTYPE html>
    <html lang=”en-US”>
    <head>
    <title>Purchase-Transaction </title>

    header blabla

    <!– Tracking code easily added by NK Google Analytics –>
    <script type=”text/javascript”>
    var _gaq = _gaq || [];
    _gaq.push( [‘_setAccount’, ‘UA-XXXXX’],[‘_trackPageview’] );

    (function() {
    var ga = document.createElement(‘script’); ga.type = ‘text/javascript’; ga.async = true;
    ga.src = (‘https:’ == document.location.protocol ? ‘https://ssl&#8217; : ‘https://www&#8217;) + ‘.google-analytics.com/ga.js’;
    var s = document.getElementsByTagName(‘script’)[0]; s.parentNode.insertBefore(ga, s);
    })();

    window.onload = function() {
    if(_gaq.I==undefined){
    _gaq.push([‘_trackEvent’, ‘tracking_script’, ‘loaded’, ‘ga.js’, ,true]);
    ga = document.createElement(‘script’); ga.type = ‘text/javascript’; ga.async = true;
    ga.src = (‘https:’ == document.location.protocol ? ‘https://ssl&#8217; : ‘https://www&#8217;) + ‘.google-analytics.com/ga.js’;
    s = document.getElementsByTagName(‘script’)[0];
    gaScript = s.parentNode.insertBefore(ga, s);
    } else {
    _gaq.push([‘_trackEvent’, ‘tracking_script’, ‘loaded’, ‘dc.js’, ,true]);
    }
    };
    </script>

    </head>
    <body>

    <h2>Transaction Completed!</h2>
    <p>Congratulations, your transaction is successful.</p>

    <script>// transaction details
    _gaq.push([‘_addTrans’,
    ‘1234’,
    ‘SitePoint’,
    ‘109.99’,
    ‘10.00’,
    ‘0.00’,
    ‘Chicago’,
    ‘Illinois’,
    ‘USA’
    ]);

    // item 1
    _gaq.push([‘_addItem’,
    ‘1234’,
    ‘css123’,
    ‘CSS Live’,
    ‘Online Course’,
    ‘9.99’,
    ‘1’
    ]);

    // item 2
    _gaq.push([‘_addItem’,
    ‘1234’,
    ‘cb999’,
    ‘Donation for Craig’s excellent blog post’,
    ‘Well-deserved bonus!’,
    ‘100’,
    ‘1’
    ]);

    // track transaction
    _gaq.push([‘_trackTrans’]);

    // load Analytics
    (function() {
    var ga = document.createElement(‘script’); ga.type = ‘text/javascript’; ga.async = true;
    ga.src = (‘https:’ == document.location.protocol ? ‘https://ssl&#8217; : ‘https://www&#8217;) + ‘.google-analytics.com/ga.js’;
    var s = document.getElementsByTagName(‘script’)[0]; s.parentNode.insertBefore(ga, s);
    })();
    </script>

    …..
    </body>
    </html>

    Any help appreciated ??

  • The topic ‘Google Analytics ecommerce tracking not working’ is closed to new replies.