Google analytics ecommerce tracking – the best way to track your sales

Google analytics happens to be the best tool to track your websites traffic,sources and other data. But very little people know about their ecommerce tracking feature. Being an era of e-commerce, were all the people buy things online, this ecommerce tracking has got high relevance.

What is google analytics ecommerce tracking?

In a normal e-commerce website, a sale is recorded when a user buys a product (or a payment  transaction  is made with respect to the product) that is when the success response is obtained from the payment gateway. We can use google analytics to track this transaction and to integrate the sales to the google analytics account.  We can pass lots of parameters like, revenue,item name,item code,currency,category,quantity,shipping charges etc to Google analytics which will be recorded  in it.

Read – How to start an ecommerce website by yourself under 100$

How to set up ecommerce tracking for your website?

  1. You need to get into the profile of your website in google analytics, every website which you have added in GA should have a profile.
  2. Go to the admin section, click the admin button on top of your analytics account.
  3. Select the particular profile of your website which you are planning to track, and its profile settings.profle
  4. In the profile setting ,if you scroll down a little bit you  can see drop down which asks you whether your website is an eccomerce site? Select Yes an ecommerce site option from the drop down and apply it. By doing this you are telling GA that your website is an ecommerce website so that the ecommerce tracking feature should be enabled.
  5. Now if you go to your reporting and select the conversions tab (on the bottom left), and then select the ecommerce section, you can see the ecommerce tracking results.  This shows the amount of sales, quantity, total value of sales, detailed product wise performace, transactions, time etc. Or in short everything you need as  a tracking for an ecommerce website.

How to setup?

You need to paste the tracking codes given below on your success page after buying a product, or in the return url from the payment gateway. In short , it should be on a page where you can get the product details and a confirmation for the payment made.

You need to  load

ga('require', 'ecommerce', 'ecommerce.js');

You need to load this after you create your tracker object. “analytics.js” doest have this ecommerce tracking script, so you need to load this separately.

There are mainly two methods to achieve this tracking.

  1. addTransaction
  2. addItem

We can add the transaction data to the object using addTransaction method.

ga('ecommerce:addTransaction', {
  'id': '1111',                     // Transaction ID. Required.
  'affiliation': 'Clothing',   // Affiliation or store name.
  'revenue': '10.5',               // Grand Total.
  'shipping': '5',                  // Shipping.
  'tax': '1.29'                     // Tax.
});

Using the addItem method we can pass the product details to ga object.

ga('ecommerce:addItem', {
  'id': '1234',                     // Transaction ID. Required.
  'name': 'Adidas ax',    // Product name. Required.
  'sku': 'DD11',                 // SKU/code.
  'category': 'Mens clothing',         // Category or variation.
  'price': '10.5',                 // Unit price.
  'quantity': '1'                   // Quantity.
});

After loading data to the object, we need to pass these data to google analytics.

ga('ecommerce:send');

After sending the data to analytics, the object will get cleared for the new transaction, or you can clear it manually.

ga('ecommerce:clear');

Putting it all together

 

The above given code loops through all the transaction details and product item data, converts them into required js format and sends to  Google analytics. Check the below screenshot of google analytics ecommerce tracking. It should look like this if everything goes good.

google analytics ecommerce tracking

 

Check for more reference
Hope you enjoyed this tutorial, we love comments, please post your opinions and suggestions as comments 🙂 .

About the author

Linjo Joson

Linjo is a PHP developer who loves to write about online businesses and marketing ideas

Add comment

Categories