Tracking your Product Sales, Views and Searches with Google Enhanced E-commerce Analytics

Enhanced E-commerce helps improving tracking of an e-commerce website. It gives Statistics in variable measurements. It is not be used alongside analytics plugin, as this EE  Plugin also tracks pages.

Enabling Enhanced Ecommerce:

Admin Section of Google Analytics Property will have three sub-sections: Account, Property View.

To enable Enhanced E-commerce you need to navigate to View > Ecommerce Settings > Turn Status & Enable Related Products to "ON" and click Submit.

Sending E-commerce Data:

Your normal Analytics Snippet will look like

<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
  ga('create', 'UA-xxxxxxxx-1', 'auto');
  ga('send', 'pageview');
</script>

Here   ga('create', 'UA-xxxxxxxx-1', 'auto') will create a page object and  ga('send', 'pageview') will send the object to google tracker. So all the Ecommerce tracking will happen in between these Lines.

Add 

ga('require', 'ec');

to load e-commerce plugin, this should be after the creation of page object.

Sample Product List View Code :

ga('create', 'UA-xxxxxxxx-1', 'auto')
ga('require', 'ec');
ga('ec:addProduct', {               // Provide product details in a productFieldObject.
  'id': 'E60152',                   // Product ID (string).
  'name': 'Sandisk Pen Drive', // Product name (string).
  'category': 'electronics',            // Product category (string).
  'brand': 'Sandisk',                // Product brand (string).
  'variant': 'On-The-Go Pendrive',               // Product variant (string).
  'custom-dimension': 'custom-answer'
});
ga('ec:setAction', 'click', {       // click action.
  'list': 'Search Results'          // Product list (string).
});
ga('send', 'pageview')

Data Types:

  1. Impression data - Data of product that is already viewed
  2. product data -  Data of a product under view.
  3. promotion data -Data of Promotion object
  4. action data. - Type of Action

In our case scenario to Track Products Sales and views, we will use product data + Action data

Similarly,

Product Detail View :

ga('ec:addProduct', {               // Provide product details in a productFieldObject.
  'id': 'E60152',                   // Product ID (string).
  'name': 'Sandisk Pen Drive', // Product name (string).
  'category': 'electronics',            // Product category (string).
  'brand': 'Sandisk',                // Product brand (string).
  'variant': 'On-The-Go Pendrive',               // Product variant (string).
  'custom-dimension': 'custom-answer'
});

ga('ec:setAction', 'detail');         ----------> Action Data

Product checkout :

ga('ec:addProduct', {               // Provide product details in a productFieldObject.
  'id': 'E60152',                   // Product ID (string).
  'name': 'Sandisk Pen Drive', // Product name (string).
  'category': 'electronics',            // Product category (string).
  'brand': 'Sandisk',                // Product brand (string).
  'variant': 'On-The-Go Pendrive',               // Product variant (string).
  'custom-dimension': 'custom-answer'
});

ga('ec:addProduct', {
  'id': 'H25482',
  'name': 'Skull Candy Go Pro Headset',
  'category': 'Accessories',
  'brand': 'Skull candy', 
  'variant': 'blue',               
});

ga('set', '&cu', 'EUR');

ga('ec:setAction', 'purchase', {
  'id': '1054412477',                         
  'revenue': '37.39',                     
});

You can view this data in Reporting > Conversions > Ecommerce.

In case if you're facing any issues, you can use GA Debug, an official chrome plugin offered by Google to view data being sent. 

Tracking Site Searches:

This can only be possible if search queries are GET queries, where we use special terms like "q=<search-term>" or "/q/<search-term>/" .. etc.,

Navigate to View Section of your account and click on "View Settings", Under "Site Search Settings" , change "Site search Tracking" to on and query parameter as the keyword after which search keyword follows, like in both the above cases query parameters is: "q".

Now you can see all the queries being made in Google Analytics under Reporting > Behaviour > Site Search.

Posted On 13 April 2015 By MicroPyramid


Need any Help in your Project?Let's Talk

Latest Comments
Related Articles
Image Cropping in Jquery (with Jcrop)

We are having many image cropping plugins developed in jquery that are being used to crop an image. Jcrop is one of the plugins developed ...

Continue Reading...
How to drag and drop multiple files using Dropzone.js

Dropzone is a free open source library which makes a HTML element as dropzone, which enables user to drag files on to that area and ...

Continue Reading...
Get tweets with Twitter API Javascript

Due to change in twitter API, its been hard to get tweets from twitter to your site using javascript. We got new API version 1.1 ...

Continue Reading...
open source packages

Subscribe To our news letter

Subscribe and Stay Updated about our Webinars, news and articles on Django, Python, Machine Learning, Amazon Web Services, DevOps, Salesforce, ReactJS, AngularJS, React Native.
* We don't provide your email contact details to any third parties