The Fresh Egg blog
Latest digital marketing news
Wait a moment! Why are you using an outdated version of Google Analytics?
Classic is the outdated version of Google Analytics. Your business is missing out on advanced features, like cross-device tracking and much more.
This guide is for Classic Google Analytics. We’ve written a guide for setting up e-commerce tracking for Universal Analytics – read it here.
If you’re considering upgrading to Universal Analytics (which you should be), check out our migration guide for Universal Analytics to upgrade to the latest tracking code.
Setting up e-commerce tracking for Google Analytics is relatively easy, although one little mistake can be enough to skew the data and provide erroneous reporting.
In this blog post, the latest in our e-commerce series, we talk you through the step-by-step process of setting up e-commerce tracking within Google Analytics.
E-commerce tracking is what allows you to measure the number of transactions and the amount of revenue generated by your website.
The e-commerce tracking for Google Analytics involves a four step process:
The first part of the process is creating the transaction object. This will contain grouped information for a single transaction, such as the total amount paid for a transaction. This will only appear once on the confirmation page. The following fields need to be added as part of the transaction object:
Below is an example of how a transaction object would be added to the confirmation page:
The second part of the process is the “item”. This will contain information about individual items in a transaction. The amount of item objects to include on the confirmation page is dependent on how many different items are purchased during a transaction, but not the quantity of those individual items. The following fields need to be added as part of the item object:
Below is an example of how to add the item object to the confirmation page:
The default currency for transactions should be set in the properties section within a Google Analytics account. If transactions can be taken with more than one currency, the currency can be added as part of the e-commerce tracking.
Below is an example of how to specify a transaction in US dollars. This must be called before the transaction is sent to Google Analytics.
The final part of the process is to send the transaction data to Google Analytics. Below is an example of how to send the transaction data to Google Analytics:
It must be noted that the "_trackTrans" command must only be added once per transaction. The only exception to this is when implementing e-commerce data for roll up profiles: the "_trackTrans" can be fired once for each roll up profile.
It is important that the standard page view tracking is included on the page that has the ecommerce tracking. The ecommerce tracking must appear after all the properties in Google Analytics (such as the ID of the Google Analytics account) have been added. It doesn't matter whether the transaction is sent to Google Analytics before the page view.
Below is a complete example of how to integrate ecommerce tracking with standard page view tracking:
The best way of testing e-commerce tracking is to use a HTTP traffic tool, such as Fiddler, Firebug or Google Developer Tools. When tracking is sent to Google Analytics, it will request a 1x1 pixel image from Google Analytics’ servers onto the page. The query string of the image URL will contain details such as the ID of the Google Analytics account. If e-commerce tracking is being sent to Google Analytics, the query string will contain details about the transaction.
The query string parameter to watch out for is "utmt". For e-commerce tracking, this should be set to "tran" if a transaction object is sent to Google Analytics. If an item object is sent to Google Analytics, the "utmt" query string parameter should be set to "item". Every item object that is sent to Google Analytics will be requested from an individual 1x1 pixel image.
Want to know more about e-commerce or tracking in Google Analytics? Contact us and one of our team will be happy to help.
Alternatively, read another of our related blog posts: