Ecommerce Tracking for your website with Google

Google can also provide you custom report for your e-commerce website with the same google analytics account which you are already using to get the traffic report of your website. For that you must enable e-commerce tracking on the profile setting page of your website.

Steps to enable e-commerce tracking
The first step of tracking e-commerce transactions is to enable e-commerce reporting for your website’s profile:
1.Sign in to your account.
2.Click Edit next to the profile you’d like to enable.
3.On the Profile Settings page, click Edit next to Main Website Profile Information.
4.Change the E-Commerce Website Drop down from “Not a E-commerce Site” to “E- Commerce site”.

The next thing you are required to do is to implement ecommerce tracking method in your shopping cart pages.With the help of these method which you have applied in your site GA will able to store this info in their db as well.Which you will get as a result in you GA report. All tracking code will be hidden that will not affect your sites functionality any more.

Tracking ecommerce using GA is possible through mainly three common functions.
I._addTrans() >> This method initialize a transaction object. With this object you can store all the related information about a single transaction like order id, transaction details, billing address, shipping address etc.
II._addItem() >> With this transaction you store your item related information at googles database. This function stores the item name, price , quantity etc.
III._trackTrans() >> This is the core function that store complete transaction when a order complete.

Below is example with complete code which tracks ecommerce activity of the website.

<title>Receipt for your clothing purchase from Acme Clothing</title>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXX-X']);
'1234',           // order ID - required
'Acme Clothing',  // affiliation or store name
'11.99',          // total - required
'1.29',           // tax
'5',              // shipping
'San Jose',       // city
'California',     // state or province
'USA'             // country
// add item might be called for every item in the shopping cart
// where your ecommerce engine loops through each item in the cart and
// prints out _addItem for each
'1234',           // order ID - required
'DD44',           // SKU/code - required
'T-Shirt',        // product name
'Green Medium',   // category or variation
'11.99',          // unit price - required
'1'               // quantity - required
_gaq.push(['_trackTrans']); //submits transaction to the Analytics servers
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
Thank you for your order.  You will receive an email containing all your order details.

You can get more detailed info at

Related posts:

The following two tabs change content below.

Chandra Shekhar

GCP Architect
Chandra Shekhar Pandey is Google certified Cloud engineer, I am Magento2 Trained developer. Having huge experience in designing cloud solution. I have around 12 years of experience with world enterprise IT companies and fortune 500 clients. During my architecture design I am always caring about high availability, fast performance and resilient system. From the programmer background I have huge experience in LAMP stack as well. Throughout my carrier I have worked on Retail, E-Learning, Video... Read More about Chandra Shekhar

Latest posts by Chandra Shekhar (see all)