0
votes

I am trying to enable ecommerce tracking on a site.

The payment part takes part inside an iframe of a third party. Once complete the iframe refreshes to a page on the main site in the same domain as the main site.

Google aynalitics is initially set up when the top page first loads with

(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', '******', 'example.com');
ga('send', 'pageview');

This part is working fine. Page tracking is working.

Once the payment has completed the iframe loads this code:

window.parent.ga('require', 'ecommerce');

window.parent.ga('ecommerce:addTransaction', {
    'id': '1234',  
    'affiliation': 'Example',  
    'revenue': '4.00',
    'shipping': '1.25', 
    'currency': 'GBP'
}); 

window.parent.ga('ecommerce:addItem', {
    'id': '1234',  
    'name': 'test product',  
    'sku': 'TEST-SKU',  
    'category': 'Test Category',         
    'price': '2.75',  
    'quantity': '1'
}); 

window.parent.ga('ecommerce:send');

I can see that network traffic is generated from this but nothing is showing up on the ecommerce analytics pages.

The ecommerce tracking options are set up on the analytics admin page

1

1 Answers

0
votes

Turns out the data just hadn't come through yet and everything was working fine. I thought the 24 hour delay was just after you turn it on, but it seems there is always at least 12 hours between transactions being made and their showing up in analytics.