Google Analytics Ecommerce Tracking Tutorial
Table of Contents for Google Analytics Ecommerce Tracking Tutorial
- What is Ecommerce Tracking in Google Analytics?
- What is Ecommerce Data in Google Analytics?
- How to set up Ecommerce Tracking in Google Analytics?
- Understanding Shopping Carts and Payment Gateways
- Ecommerce Conversion Rate
- Ecommerce Transactions and Transaction IDs
- Revenue
- Average Order Value
- Unique Purchases
- Quantity
- Average Quantity
- Product SKU
- Average Price
- Product Revenue
- Per Session Value
- Where Can You See Ecommerce Metrics in Google Analytics?
- How to Fix Common Issues with Ecommerce Tracking
- Anatomy of ECommerce Tracking Code
- Important Points about Ecommerce Tracking in Google Analytics
- Frequently Asked Questions About Ecommerce Tracking in Google Analytics
What is Google Analytics Ecommerce Tracking?
Google Analytics ecommerce tracking is a feature through which you can track ecommerce data (like sales amount, number of orders, billing location, average order value, etc) of a website/mobile app in Google Analytics.
If you run/manage an online store/app, you can’t just depend upon the analytics reports provided by your shopping cart. You need Google Analytics Ecommerce tracking set up for your website.
It is only by using Google Analytics ecommerce tracking, you can correlate sales data with website usage data like sessions, bounce rate, traffic source/medium, landing pages, etc.
Such type of correlation analysis is required in order to understand the performance of your landing pages and marketing campaigns. Otherwise, you may never know which landing pages and/or campaigns are driving sales and which are not.
With Google’s robust set of reports, we can understand which products sell well, and what are the best products viewed or bought by the customers. You can also be able to view revenue per transaction and the number of products per transaction and all this information will help you make informed decisions about your sales and business.
Ecommerce tracking is essential, not only to understand how your products and website is performing but also helps in understanding the path and variables that lead to successful conversions.
What is Ecommerce Data in Google Analytics?
The ecommerce data in Google Analytics is made up of transaction data and item data.
Transaction Data
Transaction Data provide details about users’ transactions (aka orders) like:
- Transaction ID (or order ID).
- Store or affiliation name.
- Total revenue generated from the transaction (can also include shipping cost and taxes)
- Total shipping cost associated with the transaction
- Total tax associated with the transaction.

Item Data
Item data provides details about a purchased product like:
- Transaction ID (same as in the transaction data)
- Product Name
- Product SKU (or product code).
- Product Category
- Product Price
- Product Quantity

How to set up Ecommerce Tracking in Google Analytics?
Follow the steps below to set up ecommerce tracking:
Step-1: Sign up for Google Analytics account (if you already don’t have one).
Step-2: Once you have created your Google Analytics account then navigate to https://analytics.google.com/analytics/web/
Step-3: Click on the ‘Admin’ link at the bottom left-hand side:

Step-4: Click on the ‘Tracking Info‘ drop-down menu under the ‘Property Column’:

Step-5: Click on the ‘Tracking Code’ link:

Step-6: Copy the Google Analytics tracking code (the Global Site Tag (gtag.js) tracking code) from the box under the section ‘Website Tracking‘:

Step-7: Paste the Google Analytics tracking code on all the pages of your website (in the head section <head>…</head>). If you use a template file then paste the code in the header template file like header.php.
Step-8: Navigate to your website and then navigate to Real Time > Overview report in your Google Analytics account:

If you see the number of active users in your real time overview report than it means, Google Analytics (GA) has been successfully installed on your website. However, if you see 0 number of active users then it means, GA tracking is not correctly installed:

Step-9: Navigate to Conversions > Ecommerce > Overview report:

Whenever you navigate to one of the ecommerce reports of a GA view for which ecommerce tracking is not enabled, you see the message “This report requires ecommerce tracking to be set up for the view“. You would need to enable Ecommerce reporting for each view in which you want to see the ecommerce data.
Step-10: Click on the ‘Admin’ link at the bottom left-hand side:

Step-11: Click on ‘Ecommerce Settings‘ under the view column:

Step-12: Switch on the ‘Enable Ecommerce‘ toggle button and then click on the ‘Save’ button:

You have now successfully enabled Ecommerce reporting for your view. If you now navigate back to Conversions > Ecommerce > Overview report, you would no longer see the message “This report requires ecommerce tracking to be set up for the view“:

However, you still won’t see the ecommerce data because you have not installed ecommerce tracking code on your website.
Just because you have enabled ecommerce tracking reporting in GA does not mean that you have also set up ecommerce tracking. All you have done so far is allowed your GA view to collect and report on ecommerce data.
Step-13: Integrate your shopping cart (like Shopify) with Google Analytics. Check the help documentation provided by your shopping cart for more details. Following are the help documentation for the most popular shopping carts:
- Setting up Google Analytics on Shopify Store
- Setting up Google Analytics on WooCommerce Store
- Setting up Google Analytics on Magento Store
- Setting up Google Analytics on BigCommerce Store
- Setting up Google Analytics on Drupal Store
- Setting up Google Analytics on Volusion Store
- Setting up Google Analytics on 3dCart Store
Note: Shopping cart vendors generally won’t help you in setting up ecommerce tracking for your website. You would need to hire a developer (who has experience with Google Analytics Development environment) to install ecommerce tracking for you.
Step-14: Hire a Google Analytics developer to add the ecommerce tracking code (provided by Google) on the order confirmation page (generally the ‘thank you’ page).
Here is how the ecommerce tracking code looks like (if you are using analytics.js library):
ga(‘require’, ‘ecommerce’, ‘ecommerce.js’);
ga(‘ecommerce:addTransaction’, {
‘id’: ‘1234’, // Transaction ID. Required.
‘affiliation’: ‘skinny jeans’, // store name.
‘revenue’: ‘28.8’, // total revenue.
‘shipping’: ‘10.00’, // Shipping.
‘tax’: ‘1.89’ // Tax.
});
ga(‘ecommerce:addItem’, {
‘id’: ‘1234’, // Transaction ID. Required. Same as in the transaction data.
‘name’: ‘OKEJeans’, // Product name. Required.
‘sku’: ‘SKJ49’, // Product SKU.
‘category’: ‘Men Jeans’, // Product Category or variation.
‘price’: ‘76.65’, // Product price.
‘quantity’: ‘1’ // Product Quantity.
});
ga(‘ecommerce:send’);
This ecommerce tracking code is usually placed after the following line of code ga(‘create’, ‘UA-123456-12’, ‘auto’); and just before the following code ga(‘send’, ‘pageview’);.in the Google Analytics Tracking Code:
So the whole set up may look like the one below:
<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-123456-12’, ‘auto’);
ga(‘require’, ‘ecommerce’, ‘ecommerce.js’);
ga(‘ecommerce:addTransaction’, {
‘id’: ‘1234’, // Transaction ID. Required.
‘affiliation’: ‘skinny jeans’, // store name.
‘revenue’: ‘28.8’, // total revenue.
‘shipping’: ‘10.00’, // Shipping.
‘tax’: ‘1.89’ // Tax.
});
ga(‘ecommerce:addItem’, {
‘id’: ‘1234’, // Transaction ID. Required. Same as in the transaction data.
‘name’: ‘OKEJeans’, // Product name. Required.
‘sku’: ‘SKJ49’, // Product SKU.
‘category’: ‘Men Jeans’, // Product Category or variation.
‘price’: ‘76.65’, // Product price.
‘quantity’: ‘1’ // Product Quantity.
});
ga(‘ecommerce:send’);
ga(‘send’, ‘pageview’);
</script>
Here the code in bold letters is the ecommerce tracking code. The rest is the Google Analytics tracking code.
However, this code is still not complete. To actually retrieve ecommerce data from your shopping cart, you need to add a server-side script to the code above.
Step-15: Ask your developer to add a server-side script (like PHP, ASP, etc) to your commerce tracking code. Your server-side script should loop through all the products purchased in a transaction and send product data for each of them to the Google Analytics server.
So your actual ecommerce tracking code will look very different once the server-side script is added to it.
For example, here is how your ecommerce tracking may look like, if you used PHP:
<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-123456-12’, ‘auto’);
ga(‘require’, ‘ecommerce’, ‘ecommerce.js’);
<?php
If($_SERVER[SCRIPT_NAME]==/thank-you.php”) {
?>
ga(‘ecommerce:addTransaction’, {
‘id’: ‘<? = $orders[‘order_id’]?>’,
‘affiliation’: ‘<? = $orders[‘store_name’]?>’,
‘revenue’: ‘<? = $orders[‘revenue’]?>’,
‘shipping’: ‘<? = $orders[‘shipping’]?>’,
‘tax’: ‘<? = $orders[‘tax’]?>’
});
<?php
for ($i=0;$n=sizeof($products_array);$i<$n;$i++) {
?>
ga(‘ecommerce:addItem’, {
‘id’: ‘<? = $orders[‘order_id’] ?>’,
‘name’: ‘<? =$products_array[$i][‘name’] ?>’,
‘sku’: ‘<? =$products_array[$i][‘sku’] ?>’,
‘category’: ‘<? =$products_array[$i][‘category’] ?>’,
‘price’: ‘<? =$products_array[$i][‘price’] ?>’,
‘quantity’: ‘<? =$products_array[$i][‘quantity’] ?>’
});
}
?>
ga(‘ecommerce:send’);
ga(‘send’, ‘pageview’);
</script>
Note(1): Do not use this ecommerce tracking code on your website. It is just an example and is not even a complete code.
Note(2): The actual ecommerce tracking code will vary depending upon your CMS and shopping cart.
Step-16: Set up a funnel for your checkout process in Google Analytics. To do this, first determine all of the webpages which make up your shopping cart funnel (including the URL of the order confirmation page).
To learn more about setting up funnels in GA, check out this article: The Geek Guide to Understanding Funnels in Google Analytics
Step-17: Place a test transaction and see whether you are getting the correct ecommerce data in GA reports.
Understanding Shopping Carts and Payment Gateways
In order to understand how ecommerce tracking works, you first need to know about shopping carts and payment gateways.
You can learn about, how shopping carts and payment gateways work and interact with Google Analytics, in this article: Understanding Shopping Carts for analytics and Conversion Optimization
Ecommerce Conversion Rate

Ecommerce conversion rate is the percentage of sessions that results in ecommerce transactions (in a given time period).
Ecommerce conversion rate = (Total Ecommerce Transactions/Total website sessions) * 100
For e.g. the ecommerce conversion rate in the chart above was calculated as:
= (1,736 transactions / 996,563 sessions) * 100 = 0.17%
Ecommerce Transactions and Transaction IDs
Transaction (or ecommerce transaction) is a purchase order.

For example, 1,736 transactions mean 1,736 purchase orders were placed on the website.
The ecommerce overview report shows the total number of transactions carried out on the website in a specified time period. Each transaction is identified through a unique ID known as transaction ID.

Here, 4419144621 is a transaction ID.
A single transaction can include several products or several units of the same product as a person can buy several products in one transaction or several units of the same product in one transaction. For example, a person can buy an iPhone and an iPad in a single transaction or a person can buy 10 units (or pieces) of iPhone in a single transaction.
Note: The value of transaction ID is of type ‘string’.
Revenue

The revenue that you see in the Ecommerce Overview report is the total revenue.
Total Revenue = Total Product Revenue + Total Tax + Total Shipping
For example, the total revenue in the Ecommerce Overview report was calculated as:
Total Revenue = $188,211.37 (total product revenue) + $47,371.58 (total tax) + $1,274.95 (total shipping) = $236,857.90
Your total revenue figure in the Ecommerce Overview report depends upon how the ecommerce tracking has been setup.
If your client decided to exclude tax and shipping amount from the total revenue, then your total revenue and product revenue amount would be the same.
If the tax information and/or shipping information is not supplied while setting up ecommerce tracking then Google Analytics can’t report such information in its reports and they won’t be included in the computation of total revenue.
Note: The value of revenue is of type ‘currency’.
Average Order Value

Average value or average order value (AOV) is the average value of an ecommerce transaction.
Average Value = Total Revenue/Total Transactions
For example, the AOV in the chart above was calculated as:
AOV = $236,857.90 / 1,736 = $136.44
Note: The value of Average Order Value is of type ‘currency’.
Unique Purchases

Unique purchase is the total number of times a product or a set of products was a part of a transaction.
There are two categories of unique purchases in Google Analytics:
#1 Total Unique purchases of a set of products
#2 Total Unique purchases of a product.


Note: The total unique purchases of a product are not equal to the total number of units sold for the product in one transaction. For example, the total unique purchases of the first product are 75.
But many people wrongly assume the 75 units of the first product were sold in one transaction. This is not the case.
The 75 figure tells you that the first product was a part of a transaction 75 times. It doesn’t tell you the number of units sold for the product in one transaction.
In order to find the number of units of a product which were sold in one transaction, follow the steps below:
- Click on a product link in the ‘Product Performance’ report (under Conversions > Ecommerce).
- Add ‘transaction ID’ as a ‘secondary dimension.
- Sort the ‘Unique Purchases’ column in decreasing order.
You will now see a report like the one below:

Note: The value of Unique Purchases is of type ‘number’.
Quantity

Quantity is the total number of units sold for a product or set of products. There are two categories of quantities in Google Analytics:
#1 Total number of units sold for a set of products
#2 Total number of units sold for a product.

Note: The value of quantity is of type ‘number’.
Average Quantity
Average quantity is the average number of units sold for a product or set of products in one transaction.

Average Quantity = Quantity / Unique Purchases
For example:
- The average quantity of a set of products is calculated as 3684/3242 = 1.14
- The average quantity of 1st product is calculated as 114/93 = 1.23
- The average quantity of 2nd product is calculated as 62/61 = 1.02
Note: The value of average quantity is of type ‘number’
Product SKU
Stock keeping unit or SKU is a product code that is used to uniquely identify a product.

Note: The value of product SKU is of type ‘string’
Average Price
Average price is the price of a single unit of a product.

Average price of a set of products = Total Product Revenue / Total Quantity = $3,701,278.00 / 45,226 = $81.84
Average price of the first product = price of the single unit of a product = $79

Note: The value of average price is of type ‘currency’
Product Revenue
Product revenue is the total revenue generated from a product or a set of products.

Product Revenue = Quantity * Average Price
In this example,
Total Revenue generated from a set of products is calculated as: 45,226 * $81.84 = $3,701,278.00
Total Revenue generated from the first products is calculated as: 13,281 * $79.00 = $1,049,199.00
Note(1): Product revenue doesn’t include tax and shipping charges.
Note (2): The value of average price is of type ‘currency’
Per Session Value
Per session value is the average value of a session of your ecommerce website.

Per session value = Total Revenue / Total Sessions
For example, in the chart above,
The per session value for all traffic sources is calculated as: $280,650.01 / 1,182,618 = $0.24
The per session value of the traffic from Google Organic is calculated as: $77,228.80 / 210,212 = $0.37
Higher the per session value, the more valuable the traffic is for your ecommerce business.
Note(1): You can determine per session value through ‘Ecommerce’ Tabs found in various reports.
Note (2): The ‘per session value’ is of type ‘currency’
Where Can You See Ecommerce Metrics in Google Analytics?
In order to view your ecommerce metrics in Google Analytics. Follow the below steps:
Step-1: Login to your Google Analytics reports console.
Step-2: On the left-hand navigation bar, go to ‘Conversions’ and then locate ‘E-commerce’ underneath it.

Under this subheading, you’ll be able to find the shopping and checkout behaviour of the users, transactional information, sales performance and how long it takes for the users to purchase on average.
Let us look at each tab individually and see what information it provides:
Overview Tab
This report provides you with a quick overview of what exactly is happening on the ecommerce side of your business. This report includes information like overall revenue, transactions, avg order value.

Shopping Behaviour Analysis
This report provides an insight into how new vs returning visitors behave when shopping on your site. It also shows you how users progress through a sales funnel.
If we have a look at the report, you can notice that it all starts with ‘All sessions’ on the left-hand side, followed by product views, adding to cart, checking out and making a transaction.

You can view where exactly the users are getting dropped off in each stage.
You can use this report to analyze the pain points in the customer journey. For example, if you are noticing that users are mostly getting dropped off from a particular page, you can investigate the reason and work on improving the performance of the website.
The Checkout Behaviour Analysis
With the help of this report, you can analyze how exactly the users have moved from one step to another before they reached the checkout page. Just like the shopping behaviour report, you have an option in this report which provides insights about the drop off rate at each step.

Product Performance Report
The product performance report in your analytics gives valuable insights into how customers are interacting with your online products.
In this report, you have an option to view your report by product sku, product name, product category or product brand. It gives detailed insights about how exactly each product is performing, what are top revenue-generating products.

Sales Performance Report
The sales performance tab shows sales and transactional information for individual product orders. This report provides key insights about your sales metrics like revenue, transactions delivery, refund amount etc.

Product List Performance
Product list performance gives you in-depth information on how each individual product or individual set is performing. It basically allows you to track how clusters of data of products in your online store are performing.

How to Fix Common Issues with Ecommerce Tracking
Duplicate Transactions
Duplicate transactions in Google Analytics mean a single transaction is counted more than once.
If this is the case, it completely skews your complete reporting because along with transactions it also messes up revenue, quantity and other metrics as well. To fix this issue, make sure that “_trackTrans” command is called only once per the transaction.
Make sure your thank you page loads only once or make sure user can view this page only once and the transaction is counted only once.
Ecommerce Code Firing multiple times
In some cases, there are chances that the users will bookmark the confirmation page and refresh the page. In such scenario’s the ecommerce code is fired multiple times and data is sent to Google analytics.
As a solution for this issue, we can set up a new field which will be called ‘transaction flag’. Once the transaction is completed this value should be set and ecommerce data should be sent to Google Analytics. Then, the next time the user loads the confirmation page if this value is already set then don’t send fire the ecommerce code.
Missing Transactions in Google Analytics
It is common that you would notice a discrepancy in transactions between your internal system and Google Analytics. However, if this discrepancy is more than 5% then you should investigate the reason for this issue.
There could be several reasons that you would see this issue.
Follow this article which explains the reasons for different data in your internal system and Google analytics.
JavaScript Issue for Order Values
When writing numbers to web pages, some coding languages will automatically insert commas for numeric values. Let’s say for example if the average cost of some product on your website is 1856rs, then if it is written as 1,856rs it would create a problem in Google Analytics reports.
In such cases, JavaScript would have issues parsing these values which contains commas into Google Analytics unless they are specified as a string.
To avoid this issue, we need to ensure that we do not add commas in the numeric values while sending data to Google Analytics.
Apart from these issues, there could be multiple issues with ecommerce implementation. One of the best ways to debug the issues is to use Google’s ecommerce troubleshooter. This tool helps you to identify and resolve all the issues with your ecommerce tracking and reporting.
This troubleshooter provides you with an option to select the issue and provides possible workarounds to fix it.
Anatomy of Ecommerce Tracking Code
The ecommerce tracking code is made up of the following four commands:
- ecommerce
- ecommerce:addTransaction
- ecommerce:addItem
- ecommerce:send
‘ecommerce’ command
This command is used to load the ecommerce plugin.
Syntax: ga(‘require’, ‘ecommerce’, ‘ecommerce.js’);
The plugin contains the functionality for ecommerce tracking in GA. You have to load this plugin, otherwise, your ecommerce tracking won’t work.
Note: The ‘ecommerce’ command should always be called after you have created the tracker object and before following, commands are executed: ecommerce:addTransaction, ecommerce:addItem and ecommerce:send


‘ecommerce:addTransaction’ command
This command is used to create a visitor’s transaction and to store all the information about the transaction.
Syntax:
ga(‘ecommerce:addTransaction’, {
‘id’: ‘1234’, // Transaction ID. Required.
‘affiliation’: ‘skinny jeans’, // store name.
‘revenue’: ‘28.8’, // total revenue.
‘shipping’: ‘10.00’, // Shipping.
‘tax’: ‘1.89’ // Tax.
});
‘ecommerce:addItem’ command
This command is used to add a product to a visitor’s transaction and to store all the information about the purchased product.
Syntax:
ga(‘ecommerce:addItem’, {
‘id’: ‘1234’, // Transaction ID. Required. Same as in the transaction data.
‘name’: ‘OKEJeans’, // Product name. Required.
‘sku’: ‘SKJ49’, // Product SKU.
‘category’: ‘Men Jeans’, // Product Category or variation.
‘price’: ‘76.65’, // Product price.
‘quantity’: ‘1’ // Product Quantity.
});
‘ecommerce:send’ command
This command is used to send all of the ecommerce data to the Google Analytics server.
Syntax: ga(‘ecommerce:send’);
Note: without using the command, you can’t send ecommerce data to Google Analytics.
Important Points about Ecommerce Tracking in Google Analytics
#1 It is common to have data discrepancy between Google Analytics sales data and your shopping cart sales data.
All major pre-built shopping carts have the functionality to handle canceled orders, test orders, promo/discount codes, unfulfilled orders and refund (partial or full).
Google Analytics does not have any such in-built functionality.
Once a user is served an order confirmation page, the ecommerce tracking code is executed and the transaction is recorded by GA. If the user later asks for a refund, cancels the order or the order is not fulfilled then these changes don’t automatically reflect back in GA ecommerce reports.
Thus depending upon the volume of canceled orders, refunds and unfulfilled orders your website gets every day, you may see either small or large data discrepancy between GA sales data and your shopping cart sales data.
Remember GA was never designed to function as accounting software. So do not expect 100% accuracy in sales data.
Since Shopping cart handles sales data much better than GA, so whenever you are in doubt, trust your shopping cart data more.
#2 Test orders can very easily skew your ecommerce data in Google Analytics
It is common for web developers to place test orders while testing an application. But it is not common for them to reverse test transactions in Google Analytics.
All the test orders need to be reversed, otherwise, they can greatly inflate your sales data.
Ask your developer to provide you with a list of all test orders placed on the website, at least once a month and then at least deduct them from your analysis, if you can’t reverse them.
Related Article: Fixing Duplicate, Cancelled, Test orders & Refunds in Google Analytics
#3 Data sampling issues can easily skew your ecommerce data
If your website gets more than 250k sessions a month and you don’t use GA premium, there is a good possibility that your website is suffering from data sampling issues. When GA sample your data badly, you can’t trust the metrics reported by it.
Your ecommerce data from revenue to ecommerce conversion rate could be 10 to 80% off the mark.
Avoid using advanced segments or secondary dimensions during data interpretation when you have got data sampling issues.
Related Article: Google Analytics Data Sampling – Complete Guide
#4 Watch out for Duplicate transactions
This is a very common issue I encounter while doing a GA audit.
A duplicate transaction can take place when an ecommerce tracking code is executed more than once without placing any new order. Duplicate transactions can easily skew your ecommerce data.
To fix the duplicate transaction issues, check out this article: Fixing Duplicate, Cancelled, Test orders & Refunds in Google Analytics
If you want to set up ecommerce tracking in Google Tag Manager then check out the following article: Implementing Ecommerce Tracking via Google Tag Manager
If you are interested in learning about enhanced ecommerce tracking, I have got half a dozen articles for you:
#1 Enhanced Ecommerce Tracking in Google Analytics – Beginners Guide
#2 Implementing Enhanced Ecommerce Tracking in Google Analytics – Nerd Guide
#3 Using Enhanced Ecommerce Segments for Remarketing in Google Analytics
#4 Using Cohort Analysis & Enhanced Ecommerce to Understand Users Behavior
#5 Fixing Duplicate, Cancelled, Test Orders and Refunds in Google Analytics
Other articles on specialized tracking in Google Analytics
- Ecommerce Tracking in Google Analytics – Tutorial
- Event Tracking via Google Tag Manager – Tutorial
- Event Tracking in Google Analytics – Tutorial
- Guide to Google Analytics Store Visits Tracking
- Offline Conversion Tracking in Google Analytics – Tutorial
- Implementing E-Commerce Tracking via Google Tag Manager
- Tracking Virtual Pageviews in Google Tag Manager – Tutorial
- YouTube Video tracking via Google Tag Manager
- How to Use Keyword Hero to Reveal Not Provided Keywords in Google Analytics
- Virtual pageviews in Google Analytics – Tutorial
- Google Analytics and YouTube Integration Tutorial
- Google Analytics for Facebook Tutorial
- Google Analytics Cross Domain Tracking Explained Like Never Before
- Using multiple Google Analytics tracking codes on web pages
- The one thing that you don’t know about PayPal.com and the referral exclusion list
- Calculated Metrics in Google Analytics – Tutorial
- Creating your own Google Analytics Tag Auditing System
- Tracking Site Search without Query Parameter in Google Tag Manager
- Tracking true referrals in Google Analytics when using PayPal and other payment gateways
- Phone Call Tracking in Google Analytics and Beyond
- Learn to Track Qualified and Won Leads in Google Analytics
- Introduction to Postbacks in Google Analytics
- Google Analytics Recurring Revenue and Subscriptions Tracking Tutorial
- How to track the impact of cookie consent on website traffic in Google Analytics
- Tracking Offline Conversions in Google Ads
- Implementing Scroll Tracking via Google Tag Manager
- Scroll Tracking via Scroll Depth Trigger in Google Tag Manager
- Site Search Tracking In Google Analytics Without Query Parameters
- Video Tracking via YouTube Video Trigger In Google Tag Manager
- How to Correctly Measure Conversion Date & Time in Google Analytics
- Google Analytics Social Tracking – Twitter, Facebook, Google Plus and LinkedIn
- Google Analytics Cross Domain Tracking (ga.js)
- Tracking Twitter and Linkedin Social Interactions in Google Analytics
- Creating Content Group in Google Analytics via tracking code using gtag.js
- Tracking Site Search in Google Analytics with Query Parameters
- Understanding site search tracking in Google Analytics
- Creating and Using Site Search Funnel in Google Analytics
- Learn to Setup Facebook Pixel Tracking via Google Tag Manager
- Setting up & Tracking AMP Pages in Google Analytics
- Setting up Sales Funnel across websites in Google Analytics
- Regular Expressions (Regex) for Google Analytics & Google Tag Manager – Tutorial
Frequently Asked Questions About Google Analytics Ecommerce Tracking
Why do you need ecommerce tracking?
If you run/manage an online store/app, you can’t just depend upon the analytics reports provided by your shopping cart. You need Google Analytics Ecommerce tracking set up for your website. It is only by using Google Analytics ecommerce tracking, you can correlate sales data with website usage data like sessions, bounce rate, traffic source/medium, landing pages, etc.
Such type of correlation analysis is required in order to understand the performance of your website landing pages and marketing campaigns. Otherwise, you may never know which landing pages and/or campaigns are driving sales and which are not.
What is ecommerce conversion rate?
Ecommerce conversion rate is the percentage of sessions which results in ecommerce transactions (in a given time period). Following is the formula to calculate ecommerce conversion rate:
Ecommerce conversion rate = (Total Ecommerce Transactions/Total website sessions) * 100
What is an ecommerce transaction?
Transaction (or ecommerce transaction) is a purchase order. Each transaction is identified through a unique ID known as transaction ID.
A single transaction can include several products or several units of the same product as a person can buy several products in one transaction or several units of the same product in one transaction. For example, a person can buy iPhone and an iPad in a single transaction or a person can buy 10 units (or pieces) of iPhone in a single transaction.
What is average order value?
Average value or average order value (AOV) is the average value of an ecommerce transaction.
Average Value = Total Revenue/Total Transactions
For example, the AOV in the chart above was calculated as:
AOV = $236,857.90 / 1,736 = $136.44
What are unique purchases?
Unique purchase is the total number of times a product or a set of products was a part of a transaction.
There are two categories of unique purchases in Google Analytics:
#1 Total Unique purchases of a set of products
#2 Total Unique purchases of a product.
The total unique purchases of a product is not equal to the total number of units sold for the product in one transaction.
Register for the FREE TRAINING...
"How to use Digital Analytics to generate floods of new Sales and Customers without spending years figuring everything out on your own."
Here’s what we’re going to cover in this training…
#1 Why digital analytics is the key to online business success.
#2 The number 1 reason why most marketers are not able to scale their advertising and maximize sales.
#3 Why Google and Facebook ads don’t work for most businesses & how to make them work.
#4 Why you won’t get any competitive advantage in the marketplace just by knowing Google Analytics.
#5 The number 1 reason why conversion optimization is not working for your business.
#6 How to advertise on any marketing platform for FREE with an unlimited budget.
#7 How to learn and master digital analytics and conversion optimization in record time.
My best selling books on Digital Analytics and Conversion Optimization
Maths and Stats for Web Analytics and Conversion Optimization
This expert guide will teach you how to leverage the knowledge of maths and statistics in order to accurately interpret data and take actions, which can quickly improve the bottom-line of your online business.
Master the Essentials of Email Marketing Analytics
This book focuses solely on the ‘analytics’ that power your email marketing optimization program and will help you dramatically reduce your cost per acquisition and increase marketing ROI by tracking the performance of the various KPIs and metrics used for email marketing.
Attribution Modelling in Google Analytics and Beyond
Attribution modelling is the process of determining the most effective marketing channels for investment. This book has been written to help you implement attribution modelling. It will teach you how to leverage the knowledge of attribution modelling in order to allocate marketing budget and understand buying behaviour.
Attribution Modelling in Google Ads and Facebook
This book has been written to help you implement attribution modelling in Google Ads (Google AdWords) and Facebook. It will teach you, how to leverage the knowledge of attribution modelling in order to understand the customer purchasing journey and determine the most effective marketing channels for investment.
Table of Contents for Google Analytics Ecommerce Tracking Tutorial
- What is Ecommerce Tracking in Google Analytics?
- What is Ecommerce Data in Google Analytics?
- How to set up Ecommerce Tracking in Google Analytics?
- Understanding Shopping Carts and Payment Gateways
- Ecommerce Conversion Rate
- Ecommerce Transactions and Transaction IDs
- Revenue
- Average Order Value
- Unique Purchases
- Quantity
- Average Quantity
- Product SKU
- Average Price
- Product Revenue
- Per Session Value
- Where Can You See Ecommerce Metrics in Google Analytics?
- How to Fix Common Issues with Ecommerce Tracking
- Anatomy of ECommerce Tracking Code
- Important Points about Ecommerce Tracking in Google Analytics
- Frequently Asked Questions About Ecommerce Tracking in Google Analytics
What is Google Analytics Ecommerce Tracking?
Google Analytics ecommerce tracking is a feature through which you can track ecommerce data (like sales amount, number of orders, billing location, average order value, etc) of a website/mobile app in Google Analytics.
If you run/manage an online store/app, you can’t just depend upon the analytics reports provided by your shopping cart. You need Google Analytics Ecommerce tracking set up for your website.
It is only by using Google Analytics ecommerce tracking, you can correlate sales data with website usage data like sessions, bounce rate, traffic source/medium, landing pages, etc.
Such type of correlation analysis is required in order to understand the performance of your landing pages and marketing campaigns. Otherwise, you may never know which landing pages and/or campaigns are driving sales and which are not.
With Google’s robust set of reports, we can understand which products sell well, and what are the best products viewed or bought by the customers. You can also be able to view revenue per transaction and the number of products per transaction and all this information will help you make informed decisions about your sales and business.
Ecommerce tracking is essential, not only to understand how your products and website is performing but also helps in understanding the path and variables that lead to successful conversions.
What is Ecommerce Data in Google Analytics?
The ecommerce data in Google Analytics is made up of transaction data and item data.
Transaction Data
Transaction Data provide details about users’ transactions (aka orders) like:
- Transaction ID (or order ID).
- Store or affiliation name.
- Total revenue generated from the transaction (can also include shipping cost and taxes)
- Total shipping cost associated with the transaction
- Total tax associated with the transaction.
Item Data
Item data provides details about a purchased product like:
- Transaction ID (same as in the transaction data)
- Product Name
- Product SKU (or product code).
- Product Category
- Product Price
- Product Quantity
How to set up Ecommerce Tracking in Google Analytics?
Follow the steps below to set up ecommerce tracking:
Step-1: Sign up for Google Analytics account (if you already don’t have one).
Step-2: Once you have created your Google Analytics account then navigate to https://analytics.google.com/analytics/web/
Step-3: Click on the ‘Admin’ link at the bottom left-hand side:
Step-4: Click on the ‘Tracking Info‘ drop-down menu under the ‘Property Column’:
Step-5: Click on the ‘Tracking Code’ link:
Step-6: Copy the Google Analytics tracking code (the Global Site Tag (gtag.js) tracking code) from the box under the section ‘Website Tracking‘:
Step-7: Paste the Google Analytics tracking code on all the pages of your website (in the head section <head>…</head>). If you use a template file then paste the code in the header template file like header.php.
Step-8: Navigate to your website and then navigate to Real Time > Overview report in your Google Analytics account:
If you see the number of active users in your real time overview report than it means, Google Analytics (GA) has been successfully installed on your website. However, if you see 0 number of active users then it means, GA tracking is not correctly installed:
Step-9: Navigate to Conversions > Ecommerce > Overview report:
Whenever you navigate to one of the ecommerce reports of a GA view for which ecommerce tracking is not enabled, you see the message “This report requires ecommerce tracking to be set up for the view“. You would need to enable Ecommerce reporting for each view in which you want to see the ecommerce data.
Step-10: Click on the ‘Admin’ link at the bottom left-hand side:
Step-11: Click on ‘Ecommerce Settings‘ under the view column:
Step-12: Switch on the ‘Enable Ecommerce‘ toggle button and then click on the ‘Save’ button:
You have now successfully enabled Ecommerce reporting for your view. If you now navigate back to Conversions > Ecommerce > Overview report, you would no longer see the message “This report requires ecommerce tracking to be set up for the view“:
However, you still won’t see the ecommerce data because you have not installed ecommerce tracking code on your website.
Just because you have enabled ecommerce tracking reporting in GA does not mean that you have also set up ecommerce tracking. All you have done so far is allowed your GA view to collect and report on ecommerce data.
Step-13: Integrate your shopping cart (like Shopify) with Google Analytics. Check the help documentation provided by your shopping cart for more details. Following are the help documentation for the most popular shopping carts:
- Setting up Google Analytics on Shopify Store
- Setting up Google Analytics on WooCommerce Store
- Setting up Google Analytics on Magento Store
- Setting up Google Analytics on BigCommerce Store
- Setting up Google Analytics on Drupal Store
- Setting up Google Analytics on Volusion Store
- Setting up Google Analytics on 3dCart Store
Note: Shopping cart vendors generally won’t help you in setting up ecommerce tracking for your website. You would need to hire a developer (who has experience with Google Analytics Development environment) to install ecommerce tracking for you.
Step-14: Hire a Google Analytics developer to add the ecommerce tracking code (provided by Google) on the order confirmation page (generally the ‘thank you’ page).
Here is how the ecommerce tracking code looks like (if you are using analytics.js library):
ga(‘require’, ‘ecommerce’, ‘ecommerce.js’);
ga(‘ecommerce:addTransaction’, {
‘id’: ‘1234’, // Transaction ID. Required.
‘affiliation’: ‘skinny jeans’, // store name.
‘revenue’: ‘28.8’, // total revenue.
‘shipping’: ‘10.00’, // Shipping.
‘tax’: ‘1.89’ // Tax.
});
ga(‘ecommerce:addItem’, {
‘id’: ‘1234’, // Transaction ID. Required. Same as in the transaction data.
‘name’: ‘OKEJeans’, // Product name. Required.
‘sku’: ‘SKJ49’, // Product SKU.
‘category’: ‘Men Jeans’, // Product Category or variation.
‘price’: ‘76.65’, // Product price.
‘quantity’: ‘1’ // Product Quantity.
});
ga(‘ecommerce:send’);
This ecommerce tracking code is usually placed after the following line of code ga(‘create’, ‘UA-123456-12’, ‘auto’); and just before the following code ga(‘send’, ‘pageview’);.in the Google Analytics Tracking Code:
So the whole set up may look like the one below:
<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-123456-12’, ‘auto’);
ga(‘require’, ‘ecommerce’, ‘ecommerce.js’);
ga(‘ecommerce:addTransaction’, {
‘id’: ‘1234’, // Transaction ID. Required.
‘affiliation’: ‘skinny jeans’, // store name.
‘revenue’: ‘28.8’, // total revenue.
‘shipping’: ‘10.00’, // Shipping.
‘tax’: ‘1.89’ // Tax.
});
ga(‘ecommerce:addItem’, {
‘id’: ‘1234’, // Transaction ID. Required. Same as in the transaction data.
‘name’: ‘OKEJeans’, // Product name. Required.
‘sku’: ‘SKJ49’, // Product SKU.
‘category’: ‘Men Jeans’, // Product Category or variation.
‘price’: ‘76.65’, // Product price.
‘quantity’: ‘1’ // Product Quantity.
});
ga(‘ecommerce:send’);
ga(‘send’, ‘pageview’);
</script>
Here the code in bold letters is the ecommerce tracking code. The rest is the Google Analytics tracking code.
However, this code is still not complete. To actually retrieve ecommerce data from your shopping cart, you need to add a server-side script to the code above.
Step-15: Ask your developer to add a server-side script (like PHP, ASP, etc) to your commerce tracking code. Your server-side script should loop through all the products purchased in a transaction and send product data for each of them to the Google Analytics server.
So your actual ecommerce tracking code will look very different once the server-side script is added to it.
For example, here is how your ecommerce tracking may look like, if you used PHP:
<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-123456-12’, ‘auto’);
ga(‘require’, ‘ecommerce’, ‘ecommerce.js’);
<?php
If($_SERVER[SCRIPT_NAME]==/thank-you.php”) {
?>
ga(‘ecommerce:addTransaction’, {
‘id’: ‘<? = $orders[‘order_id’]?>’,
‘affiliation’: ‘<? = $orders[‘store_name’]?>’,
‘revenue’: ‘<? = $orders[‘revenue’]?>’,
‘shipping’: ‘<? = $orders[‘shipping’]?>’,
‘tax’: ‘<? = $orders[‘tax’]?>’
});
<?php
for ($i=0;$n=sizeof($products_array);$i<$n;$i++) {
?>
ga(‘ecommerce:addItem’, {
‘id’: ‘<? = $orders[‘order_id’] ?>’,
‘name’: ‘<? =$products_array[$i][‘name’] ?>’,
‘sku’: ‘<? =$products_array[$i][‘sku’] ?>’,
‘category’: ‘<? =$products_array[$i][‘category’] ?>’,
‘price’: ‘<? =$products_array[$i][‘price’] ?>’,
‘quantity’: ‘<? =$products_array[$i][‘quantity’] ?>’
});
}
?>
ga(‘ecommerce:send’);
ga(‘send’, ‘pageview’);
</script>
Note(1): Do not use this ecommerce tracking code on your website. It is just an example and is not even a complete code.
Note(2): The actual ecommerce tracking code will vary depending upon your CMS and shopping cart.
Step-16: Set up a funnel for your checkout process in Google Analytics. To do this, first determine all of the webpages which make up your shopping cart funnel (including the URL of the order confirmation page).
To learn more about setting up funnels in GA, check out this article: The Geek Guide to Understanding Funnels in Google Analytics
Step-17: Place a test transaction and see whether you are getting the correct ecommerce data in GA reports.
Understanding Shopping Carts and Payment Gateways
In order to understand how ecommerce tracking works, you first need to know about shopping carts and payment gateways.
You can learn about, how shopping carts and payment gateways work and interact with Google Analytics, in this article: Understanding Shopping Carts for analytics and Conversion Optimization
Ecommerce Conversion Rate
Ecommerce conversion rate is the percentage of sessions that results in ecommerce transactions (in a given time period).
Ecommerce conversion rate = (Total Ecommerce Transactions/Total website sessions) * 100
For e.g. the ecommerce conversion rate in the chart above was calculated as:
= (1,736 transactions / 996,563 sessions) * 100 = 0.17%
Ecommerce Transactions and Transaction IDs
Transaction (or ecommerce transaction) is a purchase order.
For example, 1,736 transactions mean 1,736 purchase orders were placed on the website.
The ecommerce overview report shows the total number of transactions carried out on the website in a specified time period. Each transaction is identified through a unique ID known as transaction ID.
Here, 4419144621 is a transaction ID.
A single transaction can include several products or several units of the same product as a person can buy several products in one transaction or several units of the same product in one transaction. For example, a person can buy an iPhone and an iPad in a single transaction or a person can buy 10 units (or pieces) of iPhone in a single transaction.
Note: The value of transaction ID is of type ‘string’.
Revenue
The revenue that you see in the Ecommerce Overview report is the total revenue.
Total Revenue = Total Product Revenue + Total Tax + Total Shipping
For example, the total revenue in the Ecommerce Overview report was calculated as:
Total Revenue = $188,211.37 (total product revenue) + $47,371.58 (total tax) + $1,274.95 (total shipping) = $236,857.90
Your total revenue figure in the Ecommerce Overview report depends upon how the ecommerce tracking has been setup.
If your client decided to exclude tax and shipping amount from the total revenue, then your total revenue and product revenue amount would be the same.
If the tax information and/or shipping information is not supplied while setting up ecommerce tracking then Google Analytics can’t report such information in its reports and they won’t be included in the computation of total revenue.
Note: The value of revenue is of type ‘currency’.
Average Order Value
Average value or average order value (AOV) is the average value of an ecommerce transaction.
Average Value = Total Revenue/Total Transactions
For example, the AOV in the chart above was calculated as:
AOV = $236,857.90 / 1,736 = $136.44
Note: The value of Average Order Value is of type ‘currency’.
Unique Purchases
Unique purchase is the total number of times a product or a set of products was a part of a transaction.
There are two categories of unique purchases in Google Analytics:
#1 Total Unique purchases of a set of products
#2 Total Unique purchases of a product.
Note: The total unique purchases of a product are not equal to the total number of units sold for the product in one transaction. For example, the total unique purchases of the first product are 75.
But many people wrongly assume the 75 units of the first product were sold in one transaction. This is not the case.
The 75 figure tells you that the first product was a part of a transaction 75 times. It doesn’t tell you the number of units sold for the product in one transaction.
In order to find the number of units of a product which were sold in one transaction, follow the steps below:
- Click on a product link in the ‘Product Performance’ report (under Conversions > Ecommerce).
- Add ‘transaction ID’ as a ‘secondary dimension.
- Sort the ‘Unique Purchases’ column in decreasing order.
You will now see a report like the one below:
Note: The value of Unique Purchases is of type ‘number’.
Quantity
Quantity is the total number of units sold for a product or set of products. There are two categories of quantities in Google Analytics:
#1 Total number of units sold for a set of products
#2 Total number of units sold for a product.
Note: The value of quantity is of type ‘number’.
Average Quantity
Average quantity is the average number of units sold for a product or set of products in one transaction.
Average Quantity = Quantity / Unique Purchases
For example:
- The average quantity of a set of products is calculated as 3684/3242 = 1.14
- The average quantity of 1st product is calculated as 114/93 = 1.23
- The average quantity of 2nd product is calculated as 62/61 = 1.02
Note: The value of average quantity is of type ‘number’
Product SKU
Stock keeping unit or SKU is a product code that is used to uniquely identify a product.
Note: The value of product SKU is of type ‘string’
Average Price
Average price is the price of a single unit of a product.
Average price of a set of products = Total Product Revenue / Total Quantity = $3,701,278.00 / 45,226 = $81.84
Average price of the first product = price of the single unit of a product = $79
Note: The value of average price is of type ‘currency’
Product Revenue
Product revenue is the total revenue generated from a product or a set of products.
Product Revenue = Quantity * Average Price
In this example,
Total Revenue generated from a set of products is calculated as: 45,226 * $81.84 = $3,701,278.00
Total Revenue generated from the first products is calculated as: 13,281 * $79.00 = $1,049,199.00
Note(1): Product revenue doesn’t include tax and shipping charges.
Note (2): The value of average price is of type ‘currency’
Per Session Value
Per session value is the average value of a session of your ecommerce website.
Per session value = Total Revenue / Total Sessions
For example, in the chart above,
The per session value for all traffic sources is calculated as: $280,650.01 / 1,182,618 = $0.24
The per session value of the traffic from Google Organic is calculated as: $77,228.80 / 210,212 = $0.37
Higher the per session value, the more valuable the traffic is for your ecommerce business.
Note(1): You can determine per session value through ‘Ecommerce’ Tabs found in various reports.
Note (2): The ‘per session value’ is of type ‘currency’
Where Can You See Ecommerce Metrics in Google Analytics?
In order to view your ecommerce metrics in Google Analytics. Follow the below steps:
Step-1: Login to your Google Analytics reports console.
Step-2: On the left-hand navigation bar, go to ‘Conversions’ and then locate ‘E-commerce’ underneath it.
Under this subheading, you’ll be able to find the shopping and checkout behaviour of the users, transactional information, sales performance and how long it takes for the users to purchase on average.
Let us look at each tab individually and see what information it provides:
Overview Tab
This report provides you with a quick overview of what exactly is happening on the ecommerce side of your business. This report includes information like overall revenue, transactions, avg order value.
Shopping Behaviour Analysis
This report provides an insight into how new vs returning visitors behave when shopping on your site. It also shows you how users progress through a sales funnel.
If we have a look at the report, you can notice that it all starts with ‘All sessions’ on the left-hand side, followed by product views, adding to cart, checking out and making a transaction.
You can view where exactly the users are getting dropped off in each stage.
You can use this report to analyze the pain points in the customer journey. For example, if you are noticing that users are mostly getting dropped off from a particular page, you can investigate the reason and work on improving the performance of the website.
The Checkout Behaviour Analysis
With the help of this report, you can analyze how exactly the users have moved from one step to another before they reached the checkout page. Just like the shopping behaviour report, you have an option in this report which provides insights about the drop off rate at each step.
Product Performance Report
The product performance report in your analytics gives valuable insights into how customers are interacting with your online products.
In this report, you have an option to view your report by product sku, product name, product category or product brand. It gives detailed insights about how exactly each product is performing, what are top revenue-generating products.
Sales Performance Report
The sales performance tab shows sales and transactional information for individual product orders. This report provides key insights about your sales metrics like revenue, transactions delivery, refund amount etc.
Product List Performance
Product list performance gives you in-depth information on how each individual product or individual set is performing. It basically allows you to track how clusters of data of products in your online store are performing.
How to Fix Common Issues with Ecommerce Tracking
Duplicate Transactions
Duplicate transactions in Google Analytics mean a single transaction is counted more than once.
If this is the case, it completely skews your complete reporting because along with transactions it also messes up revenue, quantity and other metrics as well. To fix this issue, make sure that “_trackTrans” command is called only once per the transaction.
Make sure your thank you page loads only once or make sure user can view this page only once and the transaction is counted only once.
Ecommerce Code Firing multiple times
In some cases, there are chances that the users will bookmark the confirmation page and refresh the page. In such scenario’s the ecommerce code is fired multiple times and data is sent to Google analytics.
As a solution for this issue, we can set up a new field which will be called ‘transaction flag’. Once the transaction is completed this value should be set and ecommerce data should be sent to Google Analytics. Then, the next time the user loads the confirmation page if this value is already set then don’t send fire the ecommerce code.
Missing Transactions in Google Analytics
It is common that you would notice a discrepancy in transactions between your internal system and Google Analytics. However, if this discrepancy is more than 5% then you should investigate the reason for this issue.
There could be several reasons that you would see this issue.
Follow this article which explains the reasons for different data in your internal system and Google analytics.
JavaScript Issue for Order Values
When writing numbers to web pages, some coding languages will automatically insert commas for numeric values. Let’s say for example if the average cost of some product on your website is 1856rs, then if it is written as 1,856rs it would create a problem in Google Analytics reports.
In such cases, JavaScript would have issues parsing these values which contains commas into Google Analytics unless they are specified as a string.
To avoid this issue, we need to ensure that we do not add commas in the numeric values while sending data to Google Analytics.
Apart from these issues, there could be multiple issues with ecommerce implementation. One of the best ways to debug the issues is to use Google’s ecommerce troubleshooter. This tool helps you to identify and resolve all the issues with your ecommerce tracking and reporting.
This troubleshooter provides you with an option to select the issue and provides possible workarounds to fix it.
Anatomy of Ecommerce Tracking Code
The ecommerce tracking code is made up of the following four commands:
- ecommerce
- ecommerce:addTransaction
- ecommerce:addItem
- ecommerce:send
‘ecommerce’ command
This command is used to load the ecommerce plugin.
Syntax: ga(‘require’, ‘ecommerce’, ‘ecommerce.js’);
The plugin contains the functionality for ecommerce tracking in GA. You have to load this plugin, otherwise, your ecommerce tracking won’t work.
Note: The ‘ecommerce’ command should always be called after you have created the tracker object and before following, commands are executed: ecommerce:addTransaction, ecommerce:addItem and ecommerce:send
‘ecommerce:addTransaction’ command
This command is used to create a visitor’s transaction and to store all the information about the transaction.
Syntax:
ga(‘ecommerce:addTransaction’, {
‘id’: ‘1234’, // Transaction ID. Required.
‘affiliation’: ‘skinny jeans’, // store name.
‘revenue’: ‘28.8’, // total revenue.
‘shipping’: ‘10.00’, // Shipping.
‘tax’: ‘1.89’ // Tax.
});
‘ecommerce:addItem’ command
This command is used to add a product to a visitor’s transaction and to store all the information about the purchased product.
Syntax:
ga(‘ecommerce:addItem’, {
‘id’: ‘1234’, // Transaction ID. Required. Same as in the transaction data.
‘name’: ‘OKEJeans’, // Product name. Required.
‘sku’: ‘SKJ49’, // Product SKU.
‘category’: ‘Men Jeans’, // Product Category or variation.
‘price’: ‘76.65’, // Product price.
‘quantity’: ‘1’ // Product Quantity.
});
‘ecommerce:send’ command
This command is used to send all of the ecommerce data to the Google Analytics server.
Syntax: ga(‘ecommerce:send’);
Note: without using the command, you can’t send ecommerce data to Google Analytics.
Important Points about Ecommerce Tracking in Google Analytics
#1 It is common to have data discrepancy between Google Analytics sales data and your shopping cart sales data.
All major pre-built shopping carts have the functionality to handle canceled orders, test orders, promo/discount codes, unfulfilled orders and refund (partial or full).
Google Analytics does not have any such in-built functionality.
Once a user is served an order confirmation page, the ecommerce tracking code is executed and the transaction is recorded by GA. If the user later asks for a refund, cancels the order or the order is not fulfilled then these changes don’t automatically reflect back in GA ecommerce reports.
Thus depending upon the volume of canceled orders, refunds and unfulfilled orders your website gets every day, you may see either small or large data discrepancy between GA sales data and your shopping cart sales data.
Remember GA was never designed to function as accounting software. So do not expect 100% accuracy in sales data.
Since Shopping cart handles sales data much better than GA, so whenever you are in doubt, trust your shopping cart data more.
#2 Test orders can very easily skew your ecommerce data in Google Analytics
It is common for web developers to place test orders while testing an application. But it is not common for them to reverse test transactions in Google Analytics.
All the test orders need to be reversed, otherwise, they can greatly inflate your sales data.
Ask your developer to provide you with a list of all test orders placed on the website, at least once a month and then at least deduct them from your analysis, if you can’t reverse them.
Related Article: Fixing Duplicate, Cancelled, Test orders & Refunds in Google Analytics
#3 Data sampling issues can easily skew your ecommerce data
If your website gets more than 250k sessions a month and you don’t use GA premium, there is a good possibility that your website is suffering from data sampling issues. When GA sample your data badly, you can’t trust the metrics reported by it.
Your ecommerce data from revenue to ecommerce conversion rate could be 10 to 80% off the mark.
Avoid using advanced segments or secondary dimensions during data interpretation when you have got data sampling issues.
Related Article: Google Analytics Data Sampling – Complete Guide
#4 Watch out for Duplicate transactions
This is a very common issue I encounter while doing a GA audit.
A duplicate transaction can take place when an ecommerce tracking code is executed more than once without placing any new order. Duplicate transactions can easily skew your ecommerce data.
To fix the duplicate transaction issues, check out this article: Fixing Duplicate, Cancelled, Test orders & Refunds in Google Analytics
If you want to set up ecommerce tracking in Google Tag Manager then check out the following article: Implementing Ecommerce Tracking via Google Tag Manager
If you are interested in learning about enhanced ecommerce tracking, I have got half a dozen articles for you:
#1 Enhanced Ecommerce Tracking in Google Analytics – Beginners Guide
#2 Implementing Enhanced Ecommerce Tracking in Google Analytics – Nerd Guide
#3 Using Enhanced Ecommerce Segments for Remarketing in Google Analytics
#4 Using Cohort Analysis & Enhanced Ecommerce to Understand Users Behavior
#5 Fixing Duplicate, Cancelled, Test Orders and Refunds in Google Analytics
Other articles on specialized tracking in Google Analytics
- Ecommerce Tracking in Google Analytics – Tutorial
- Event Tracking via Google Tag Manager – Tutorial
- Event Tracking in Google Analytics – Tutorial
- Guide to Google Analytics Store Visits Tracking
- Offline Conversion Tracking in Google Analytics – Tutorial
- Implementing E-Commerce Tracking via Google Tag Manager
- Tracking Virtual Pageviews in Google Tag Manager – Tutorial
- YouTube Video tracking via Google Tag Manager
- How to Use Keyword Hero to Reveal Not Provided Keywords in Google Analytics
- Virtual pageviews in Google Analytics – Tutorial
- Google Analytics and YouTube Integration Tutorial
- Google Analytics for Facebook Tutorial
- Google Analytics Cross Domain Tracking Explained Like Never Before
- Using multiple Google Analytics tracking codes on web pages
- The one thing that you don’t know about PayPal.com and the referral exclusion list
- Calculated Metrics in Google Analytics – Tutorial
- Creating your own Google Analytics Tag Auditing System
- Tracking Site Search without Query Parameter in Google Tag Manager
- Tracking true referrals in Google Analytics when using PayPal and other payment gateways
- Phone Call Tracking in Google Analytics and Beyond
- Learn to Track Qualified and Won Leads in Google Analytics
- Introduction to Postbacks in Google Analytics
- Google Analytics Recurring Revenue and Subscriptions Tracking Tutorial
- How to track the impact of cookie consent on website traffic in Google Analytics
- Tracking Offline Conversions in Google Ads
- Implementing Scroll Tracking via Google Tag Manager
- Scroll Tracking via Scroll Depth Trigger in Google Tag Manager
- Site Search Tracking In Google Analytics Without Query Parameters
- Video Tracking via YouTube Video Trigger In Google Tag Manager
- How to Correctly Measure Conversion Date & Time in Google Analytics
- Google Analytics Social Tracking – Twitter, Facebook, Google Plus and LinkedIn
- Google Analytics Cross Domain Tracking (ga.js)
- Tracking Twitter and Linkedin Social Interactions in Google Analytics
- Creating Content Group in Google Analytics via tracking code using gtag.js
- Tracking Site Search in Google Analytics with Query Parameters
- Understanding site search tracking in Google Analytics
- Creating and Using Site Search Funnel in Google Analytics
- Learn to Setup Facebook Pixel Tracking via Google Tag Manager
- Setting up & Tracking AMP Pages in Google Analytics
- Setting up Sales Funnel across websites in Google Analytics
- Regular Expressions (Regex) for Google Analytics & Google Tag Manager – Tutorial
Frequently Asked Questions About Google Analytics Ecommerce Tracking
Why do you need ecommerce tracking?
If you run/manage an online store/app, you can’t just depend upon the analytics reports provided by your shopping cart. You need Google Analytics Ecommerce tracking set up for your website. It is only by using Google Analytics ecommerce tracking, you can correlate sales data with website usage data like sessions, bounce rate, traffic source/medium, landing pages, etc.
Such type of correlation analysis is required in order to understand the performance of your website landing pages and marketing campaigns. Otherwise, you may never know which landing pages and/or campaigns are driving sales and which are not.
What is ecommerce conversion rate?
Ecommerce conversion rate is the percentage of sessions which results in ecommerce transactions (in a given time period). Following is the formula to calculate ecommerce conversion rate:
Ecommerce conversion rate = (Total Ecommerce Transactions/Total website sessions) * 100
What is an ecommerce transaction?
Transaction (or ecommerce transaction) is a purchase order. Each transaction is identified through a unique ID known as transaction ID.
A single transaction can include several products or several units of the same product as a person can buy several products in one transaction or several units of the same product in one transaction. For example, a person can buy iPhone and an iPad in a single transaction or a person can buy 10 units (or pieces) of iPhone in a single transaction.
What is average order value?
Average value or average order value (AOV) is the average value of an ecommerce transaction.
Average Value = Total Revenue/Total Transactions
For example, the AOV in the chart above was calculated as:
AOV = $236,857.90 / 1,736 = $136.44
What are unique purchases?
Unique purchase is the total number of times a product or a set of products was a part of a transaction.
There are two categories of unique purchases in Google Analytics:
#1 Total Unique purchases of a set of products
#2 Total Unique purchases of a product.
The total unique purchases of a product is not equal to the total number of units sold for the product in one transaction.
Register for the FREE TRAINING...
"How to use Digital Analytics to generate floods of new Sales and Customers without spending years figuring everything out on your own."
Here’s what we’re going to cover in this training…
#1 Why digital analytics is the key to online business success.
#2 The number 1 reason why most marketers are not able to scale their advertising and maximize sales.
#3 Why Google and Facebook ads don’t work for most businesses & how to make them work.
#4 Why you won’t get any competitive advantage in the marketplace just by knowing Google Analytics.
#5 The number 1 reason why conversion optimization is not working for your business.
#6 How to advertise on any marketing platform for FREE with an unlimited budget.
#7 How to learn and master digital analytics and conversion optimization in record time.
My best selling books on Digital Analytics and Conversion Optimization
Maths and Stats for Web Analytics and Conversion Optimization
This expert guide will teach you how to leverage the knowledge of maths and statistics in order to accurately interpret data and take actions, which can quickly improve the bottom-line of your online business.
Master the Essentials of Email Marketing Analytics
This book focuses solely on the ‘analytics’ that power your email marketing optimization program and will help you dramatically reduce your cost per acquisition and increase marketing ROI by tracking the performance of the various KPIs and metrics used for email marketing.
Attribution Modelling in Google Analytics and Beyond
Attribution modelling is the process of determining the most effective marketing channels for investment. This book has been written to help you implement attribution modelling. It will teach you how to leverage the knowledge of attribution modelling in order to allocate marketing budget and understand buying behaviour.
Attribution Modelling in Google Ads and Facebook
This book has been written to help you implement attribution modelling in Google Ads (Google AdWords) and Facebook. It will teach you, how to leverage the knowledge of attribution modelling in order to understand the customer purchasing journey and determine the most effective marketing channels for investment.