Is this acceptable? Calling the pageview in the header, and then sending an event(s) further down the page?
//head
ga('create', 'UA-XXXXX-Y');
ga('require', 'ec');
ga('send', 'pageview');
//inside product details/body
ga('ec:addProduct', {
'id': 'P12345',
'name': 'Android Warhol T-Shirt',
'category': 'Apparel',
'brand': 'Google',
'variant': 'black'
});
ga('ec:setAction', 'detail');
ga('send', 'event')
Would this be better practice?
//head
ga('create', 'UA-XXXXX-Y');
ga('require', 'ec');
//inside product details/body
ga('ec:addProduct', {
'id': 'P12345',
'name': 'Android Warhol T-Shirt',
'category': 'Apparel',
'brand': 'Google',
'variant': 'black'
});
ga('ec:setAction', 'detail');
//somewhere near footer
ga('send', 'pageview');
In terms of the syntax for the event push, when you send an event to GA, you have to include the category and action (as specified here https://developers.google.com/analytics/devguides/collection/analyticsjs/events). So you would have in your event push:
ga('send', 'event', 'eventCategory', 'eventAction');
Your eCommerce transaction looks fine.
Not sure about the strategy of sending an event with your pageview though. Usually an event is associated with some action (like a button or link click).
Hope this helps.