Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 408
Simon Pederick Avatar asked Jun 30 '14 01:06

Simon Pederick


People also ask

What is GA enhanced ecommerce?

Google Analytics Enhanced Ecommerce enables product impression, promotion, and sales data to be sent with any of your Google Analytics pageviews and events. Use pageviews to track product impressions and product purchases; and use events to track checkout steps and product clicks.

How do I add a pageview in Google Analytics?

First, create a new Google Analaytics tag, or copy an existing one, and set its type to “Pageview”, then check “Enable overriding settings in this tag”. Expand “More Settings” and “Fields to Set”. Finally, add 2 new fields and put “page” and “title” for field names.


1 Answers

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.

like image 195
Eduardo Avatar answered Oct 02 '22 05:10

Eduardo