A Comprehensive Guide To Track E-commerce Transactions With Google Analytics

julia ching

Posted by admin Dec 27, 2017


E-Commerce tracking!!! Isn’t that the word coined by Google when they introduced Google Analytics? Turns out that Google Analytics is still the best tool to track E-commerce transactions.

So, what’s the catch here?

The catch is quite simple, by the means of this post, you will learn about the methods of tracking your e-commerce google analytics transaction. But first, you need to understand why tracking is crucial for eCommerce Websites.

Benefits Of eCommerce Google Analytics Transaction

In order to understand the benefits of eCommerce google analytics transaction, you need to know the list of data that would become available after enabling tracking. When you enable E-commerce tracking, you will be able to study,

  • ROI generated by each and all of your E-commerce products
  • Number of product sold
  • What is the rate of conversion?
  • How many transactions took place?
  • How many of them were unique purchases?
  • What is the average value of the orders made?
  • Performance data aligned with the date.

With all these data coming handy, you will be able to understand some very important insights of your Ecommerce website. It is the product which is really a hit on your website and second, those products who are lagging in sales. These important insights will help you to revamp your marketing strategies to maximize the profit.

The Google Analytics feature will help you in understanding the sales conundrum. In order to revamp your E-commerce marketing strategies you need to be sure about these data and as you will be sure about these, you can easily increase the conversion rate of your website with the necessary changes.

How Exactly Are The Transactions Tracked?

You want to know about “How you can track your E-commerce transaction?” But first, you need to be clear how Google tracks the transactions.

The procedure follows like this,

  • A user completes the transactions.
  • When he processed in your eCommerce platform, that verifies the payment mode, transaction detail storing, the receipt, and the transaction date.
  • These above elements are all become available for tracking.
  • For a visitor, the transaction is complete, but as soon as it ends for the visitor, your website browser will send that data to Google Analytics server securely.

So, these are the parameters through which Google Analytics is able to track all your eCommerce transactions.

Let’s talk about how you can enable Google Analytics E-commerce transaction tracking.

Enable Ecommerce Tracking in Google Analytics

Let’s divide the process it into smaller sections so that you can have a better understanding of the task at hand.

Get Google Analytics Account

It is the most rudimentary step, where you can track eCommerce transactions. Get an account first. If you already have that, well then let’s move forward.

Now, Enable Tracking in Your Google Analytics Account

So, you are done with the account creation. Now’s the time to move things forward. You need to enable E-commerce tracking in your Google Analytics account. How to do that? Follow my lead here,

  • First, sign in with your Google Analytics account
  • Then, choose your desired account
  • Click on the “Admin” tab located in the top navigation.
  • Select “e-commerce” setting in the third column from the left.
  • Now, there you will find a toggle switch labeled with “Enable Ecommerce”. Switch that button On.

With the last step, you have successfully enabled the E-commerce transaction tracking in your Google Analytics account.

Now, all you need are the tracking codes which will guide the Google Analytics to track down your eCommerce transactions.

Add The Tracking Codes

In this section of the post, you will get to know all the essential tracking codes that are required to successfully initiate ecommerce google analytics transaction. First, you need to give the code to start a new transaction.

The New Transaction Code

Use this Javascript code to initiate the transaction in your Ecommerce website.

ga(‘ecommerce:addTransaction’, {
‘id’: ‘[IDfortransaction]’,
‘affiliation’: ‘[Nameofstore]’,
‘revenue’: ‘[thetotalCost]’,
‘shipping’: ‘[Costofshipping]’,
‘tax’: ‘[Totaltax]’,
‘currency’: ‘[currency]’

Allow me to define these codes for you so that you can have a better understanding of how to use these code so that they can work properly.

  • [IDfortransaction]: This code is required. It is your unique transaction identifier
  • [Nameofstore]: This code is optional. In this code use your store name such as “WalMart”.
  • [thetotalCost]: This code is also optional. You can include the total cost including taxes and shipping.
  • [Costofshipping]: This code is optional. You must use the numeric cost of the shipping you are charging your customers.
  • [Totaltax]: You can use this optional code for defining the costs of your taxes separately in numeric form.
  • [currency]: You already defined the default currency when you set up for an e-commerce website. Still, if you want you can define it here as well with a 3-character ISO 4217 country code.

Adding Items To A Transaction

This is the next step you need to take when giving commands for tracking your eCommerce transactions. You can add items to an existing transaction with the following snippet,

ga(‘ecommerce:addItem’, {
‘id’: ‘[IDfortransaction]’,
‘name’: ‘[Nameofproduct]’,
‘sku’: ‘[Codeoftheproduct]’,
‘category’: ‘[Nameofcategory]’,
‘price’: ‘[price]’,
‘quantity’: ‘[quantity]’

The codes in this snippet have the same meaning like the above one. Also, you need to make sure that [IDfortransaction] and [Nameofproduct] mandatory fields in these codes. You need to define it or else Google will not track the transaction.

There are some functions which are important when you are defining your e-commerce attributes. Some of them are given below,

  • Clear Items in your transaction list
  • Submitting the Transaction to the Google Analytics

This brings us to,

The Final Code

The HTML coding in your Ecommerce final page which is commonly known as final confirmation screen will look something like this,

<!DOCTYPE html>
<title>Thanks for the order</title>
<h1>Thanks for the order</h1>
<p>A receipt has been sent to you@youremail.com</p>
<!– standard GA code –>
window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date;
ga(‘create’, ‘UA-XXXXX-Y’, ‘auto’);
ga(‘send’, ‘pageview’);
<script async src=’https://www.google-analytics.com/analytics.js’></script>
// enable the ecommerce features
ga(‘require’, ‘ecommerce’);
// start the transaction
ga(‘ecommerce:addTransaction’, {
‘id’: ‘10001’,
‘affiliation’: ‘My Store’,
‘revenue’: ‘54.97’,
‘shipping’: ‘5.00’,
‘tax’: ‘0.00’
});// add item 1
ga(‘ecommerce:addItem’, {
‘id’: ‘10001’,
‘name’: ‘Learn Analytics’,
‘sku’: ‘BOOK0001’,
‘category’: ‘book’,
‘price’: ‘14.99’,
‘quantity’: ‘1’
});// add item 2
ga(‘ecommerce:addItem’, {
‘id’: ‘10001’,
‘name’: ‘Learn SEO’,
‘sku’: ‘BOOK0002’,
‘category’: ‘book’,
‘price’: ‘14.99’,
‘quantity’: ‘1’
});// add item 3
ga(‘ecommerce:addItem’, {
‘id’: ‘10001’,
‘name’: ‘Learn Designing’,
‘sku’: ‘BOOK0003’,
‘category’: ‘book’,
‘price’: ‘19.99’,
‘quantity’: ‘1’
});// send transaction


Once you are done with the code, you’ll be able to view all your transactions in Google Analytics within few hours. You can find the transaction details in Conversions→ E-commerce Section of Google Analytics.

For more references, you can go through these links below,

  • Enhanced Ecommerce
  • E-commerce Tracking

I do hope that you like my post. If you think there is another facet of these codes, then please share with me. I would love to receive any type of update on these codes. Thanks for your time and patience. Happy tracking!!!

Let’s help you setup Google Analytics for your eCommerce Website

Hire us today!

Contact us

What to read next

We'd love to hear from you! Send us a message or Call us, and we'll be happy to set up a time to understand your needs better.

Our Clients, Our Pride

Get a Call Back