I'm attempting to migrate our site to Universal Analytics as well as the Enhanced Ecommerce services. After some experimentation using the GA debugger, it appears that you must call ga('send', 'pageview')
after you have called your ga('ec:addProduct')
and ga('ec:setAction')
methods to actually send the data.
When looking through the doc (https://developers.google.com/analytics/devguides/collection/analyticsjs/enhanced-ecommerce)
some examples show that they call ga('send', 'pageview')
twice, once at the beginning and a second time after setting the product data, while in other examples, ga('send', 'pageview')
is only present at the end.
ga('create', 'UA-XXXXX-Y');
ga('send', 'pageview'); /*FIRST PAGE VIEW CALLED HERE */
ga('require', 'ec', 'ec.js');
ga('ec:addProduct', {
'id': 'P12345',
'name': 'Android Warhol T-Shirt',
'category': 'Apparel',
'brand': 'Google',
'variant': 'black'
'price': '29.20',
'quantity': 1
});
// Transaction level information is provided via an actionFieldObject.
ga('ec:setAction', 'purchase', {
'id': 'T12345',
'affiliation': 'Google Store - Online',
'revenue': '37.39',
'tax': '2.85',
'shipping': '5.34',
'coupon': 'SUMMER2013' // User added a coupon at checkout.
});
ga('send', 'pageview'); // Send transaction data with initial pageview. /*BUT WE ALREADY CALLED IT AT THE TOP */
Will the above code result in the page view being logged twice?
We also want to track our customers progression through the checkout using ga('ec:setAction', 'checkout', {'step' : step});
and specifiying the step number which we have defined in our analytics account. It appears we need to call send pageview again to send this data as well. I attempted to send all the data in a single page view but it appears you can only set one action (ga('ec.setAction')
) per pageview so we can't send both the product transaction data as well as the checkout step data in a single page view. Will calling ga('send', 'pageview')
multiple times log multiple page views in analytics or does google detect that your simple sending additional data and doesn't log the extra page views?
I've found that when using normal eCommerce tracking you can use ga('ecommerce:send');
, is their an equivalent in enhanced eCommerce tracking?
addProduct
event, but not mypurchase
action. – Trey Copeland