Clive Portman: code

Ecommerce tracking with Google Analytics, ExpressionEngine and Expresso Store

Make sure the tracking is installed by adding:

ga('require', 'ecommerce');

to your analytics code (which absolutely needs to be in the <head>, then add this on your thank you page:

ga('ecommerce:addTransaction', {
  'id': '#{order_id}',
  'affiliation': "Name of store",
  'revenue': '{order_total}',
  'shipping': '{order_shipping}',
  'tax': '0'
});
{items}
{exp:channel:entries entry_id="{entry_id}"}
ga('ecommerce:addItem', {
  'id': '{entry_id}',
  'name': "{title}",
  'sku': '{sku}',
  'category': '{categories limit="1"}{category_name}{/categories}',
  'price': '{price_raw}', 
  'quantity': '{item_qty}'
});
{/exp:channel:entries}
{/items}
ga('ecommerce:send');