e-commerce tracking in Google Analytics

Google Analytics Ecommerce tracking with Google Tag Manager

If you are running an e-commerce website or an online store, tracking your transactions becomes utterly significant. This data can easily be provided by your shopping cart. But tracking transactions is all you need? How to know which marketing strategy is working wonders for you and which one is just gulping money without even a burp? Mapping website usage of your users to transactions will help you answer all such questions. One of the most powerful tools to track your website’s usage and performance is available online and available free!

Yes, you heard that right. Google Analytics will help you to track website usage and gives justice to your marketing efforts by mapping it against the sales data.

To fasten up the implementation process and reduce the workload over your development team, Google Tag Manager (another free tool) can be used to send the e-commerce data to Google Analytics. Google Tag Manager efficiently fulfills the tracking requirements with reduced hardcode on the website.

In this article, we will be covering the standard e-commerce implementation with Google Tag Manager.

Before jumping to the implementation, let’s understand what data comes under standard e-commerce reports.

With standard implementation, we can see the following sales data in Google Analytics:

Product Performance Report
It will allow you to view the website revenue at a product level. With the product name, product ID, we can easily analyze what products are driving more revenue and what products are not working so well. Further, this data can be segmented on the basis of the product categories defined on your website. For example, you might want to know whether Polo T-shirts for men are driving more revenue or Checked shirts for men. Google Analytics helps you to view this consolidated sales data and map it against your marketing efforts.

Sales Performance Report
It allows you keeping a track of your daily revenue by mapping it against the date of purchase. This report will definitely help you in gauging the success rate of your offline marketing campaigns. Let’s say you ran an offline marketing campaign, keeping your online marketing budgets constant. And, you suddenly see a significant hike in your daily revenue. Then you know that your offline marketing effort has worked well for you.

Transactions Report
To ensure that your e-commerce reporting is working properly, you can see the revenue against corresponding transaction IDs. This report helps you gauge the accuracy of your e-commerce implementation set up.

Time to Purchase Report
This report tells us the usual behavior of your users who buy from your website. How many days did it take to complete a purchase after interacting with your marketing campaign? By analyzing this behavior, you can optimize your marketing strategies according to the time taken by users to convert.

How to setup e-commerce tracking in Google Analytics

To view e-commerce reports in Google Analytics, first, we need to enable e-commerce tracking in Google Analytics. So if you haven’t already, you can enable it by following the below steps:

Click Admin from the sidebar

Select Ecommerce Settings under View

Enable Ecommerce

E-commerce tracking with Google Tag Manager

Google Tag Manager Container Code

The GTM container code has to be placed on every page of the website just like your normal Google Analytics tracking code. We need to ensure that Google Analytics tracking code is removed from the website once GTM is implemented successfully. To implement Google Tag Manager on your website:

Following code snippet has to be placed under the <head> tag as high as possible, replacing GTM-XXXX with your container ID:

Following code snippet has to be placed under the <body> tag as high as possible, replacing GTM-XXXX with your container ID:

Create a Universal Tracking tag

Create a new tag.

Select the tag type as Universal Analytics.

Enable overriding settings in this tag and add tracking ID from Google Analytics (under property settings)

Under Fields to Set, add Field Name as cookieDomain with value auto.

Add a pageview trigger to this tag, tracking All Pageviews.

Google Tag Manager datalayer code 

Datalayer is a method which is used to retrieve data from your website in Google Tag Manager and send it to Google Analytics. It is extremely important to place the Google Tag Manager datalayer code properly on your website, otherwise, you may not be able to see accurate data in Google Analytics.

The following code has to be placed on the “Thank You page” or the “Confirmation page” of your website.

You need to modify the above code such that it retrieves e-commerce data into the corresponding variables.

This code has to be placed right above the Google Tag Manager code in the <head> tag.

To ensure that your datalayer fires correctly, we need to add an additional variable – ‘event’: ‘transactioncomplete’. (You can put any value here and paste the same value while creating a custom event in GTM)

NOTE: dataLayer is case sensitive i.e. Datalayer or DataLayer is not same as dataLayer. We need to write dataLayer in the code as it is predefined in Google Tag Manager container code.

Google Analytics E-commerce tag and trigger

Create a new trigger and select the trigger type as ‘Custom Event’.

Put Event name as .*  and enable Use regex matching.

Select Some Custom Events.

Set condition as Event contains transactioncomplete (or the value defined in event variable under datalayer code on the website)

Create a new tag and select Universal Analytics tag type.

Set Track Type as Transaction.

Enable overriding settings in this tag and add tracking ID from Google Analytics (under property settings)

Add the transaction trigger to the e-commerce tag.

Publish the Google Tag Manager container.

NOTE: It may take up to 48 hours for data to reflect in your Google Analytics reports.

If you face any issues while implementing standard e-commerce, feel free to post your queries in the comment section below.

Read Also:   Google Analytics: Track Users Not Devices

If you need help with implementing the standard e-commerce or want to dive deeper with the Google Analytics enhanced e-commerce setup, you can contact us here.

Share this: