When and how often do you call ga('send', 'pageview') when using Enhanced Ecommerce with Google Analytics?

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?

Answers

It looks like you should send the event as nonInteractive:

ga('send', 'event', 'ecommerce', 'purchase', {'nonInteraction': true});

This is taken and slightly modified from @Blexy here:

https://stackoverflow.com/questions/25140579/tracking-catalog-product-impressions-enhanced-ecommerce-google-analytics

Posted on by Mike T

Google suggests this in their example, however, I have to spread this code out among the page:

ga('create', 'UA-XXXXX-Y');
ga('require', 'ec');

ga('ec:addProduct', {
  'id': 'P12345',
  'name': 'Android Warhol T-Shirt',
  'category': 'Apparel',
  'brand': 'Google',
  'variant': 'black'
});

ga('ec:setAction', 'detail');

ga('send', 'pageview');  

I have replaced the above code with the following:

ga('create', 'UA-XXXXX-Y');
ga('require', 'ec');
ga('send', 'pageview');  

ga('ec:addProduct', {
  'id': 'P12345',
  'name': 'Android Warhol T-Shirt',
  'category': 'Apparel',
  'brand': 'Google',
  'variant': 'black'
});

ga('ec:setAction', 'detail');
ga('send', 'event')

Posted on by Anonymous

Every time you call ga('send', 'pageview'), a new pageview will be sent to GA. If you just want to send more data you can also send an event to avoid the double pageview tracking.

Posted on by Eduardo