Setting Up Enhanced Ecommerce with Google Tag Manager

Setting Up Enhanced Ecommerce with Google Tag Manager

Enhanced ecommerce using Google Tag Manager

Firstly, Enhanced Ecommerce reporting is one the most valuable ways of enriching the data collected by Google Analytics. It generates a series of reports by enabling additional metrics and dimensions to capture data on user interactions with your products or services on your website store. Enhanced E-commerce tracking in Google Analytics is superior to Standard Ecommerce and so we won’t spend long on that.

Secondly, Standard Ecommerce only captures transactions and uses a different category format. Only Enhanced Ecommerce captures product related custom dimensions and metrics. Further, be careful about leaving your old Standard Ecommerce tracking in place because this could result in double-counting transactions.

Enhanced ecommerce also allows you to track interactions and transactions that are often important steps in your conversion funnel. This means you can create automated complex funnel visualisation reports in Data Studio.

1. Enable Ecommerce in Google Analytics:

Sign into your Google Analytics property and select an appropriate view. You may want to create a new view for Enhanced E-commerce depending on what data you are collecting and how you want to analyse it.

Next go to the ‘Admin’ cog and under the ‘View’ settings select ‘Ecommerce Settings’. You should now select ‘Enable Ecommerce’ and also ‘Enable Enhanced Ecommerce Reporting’ so that both are turned on. You can also create labels for the checkout-funnel steps in your ecommerce tracking code if appropriate. These can only be the steps after product have been added to the cart and before purchase.

Enable Ecommerce reporting in Google Analytics

3. Implement a Datalayer for Enhanced Ecommerce

Many popular ecommerce platforms have built in ecommerce datalayers, whilst others such as WooCommerce, allow for plugins. However, for other sites you will need to implement a generic datalayer according to Google’s template. In this post we will take you through the use of a datalayer. This means you will require access to the backend php code and so you will need to work with a developer to implement your datalayer.

You will find examples of datalayer scripts for different activities of Enhanced Ecommerce in the Google documentation here. It is important that you use the correct syntax for all the keys in JavaScript and only change items such as the event name and the values for the variables that you need to capture. You can view all the correct enhanced ecommerce keys here. Enhanced ecommerce allows you to capture website data on a whole range of user interactions including;

  • Product impressions
  • Product clicks
  • Add/remove from cart
  • Promotion clicks
  • Checkout
  • Purchase
  • Refunds

GTM will also only respond to a datalayer.push() commands and so below I have outlined examples of the script to use with some best practices. This includes a couple of best practices such as checking the datalayer is already present (Var dataLayer = window.dataLayer | | []; ) and including an event key (e.g. an ’event’: ‘transaction’ for purchase) which is not present in the Google documentation.

Ecommerce Purchase:


Var dataLayer = window.dataLayer | | [];


‘event’: ‘Transaction’,

‘ecommerce’: {

‘purchase’ : {

‘actionField’: {

‘id’: ‘d293495943’, //Transaction ID. Required for purchases and refunds.

‘revenue’: ‘45.50’,

‘tax’: ‘9.00’,

‘shipping’: ‘4.99’,


‘Products’: [{

‘name’: ‘iPhone11’, //Name or ID is required.

‘id’: ‘j12345’,

‘price’: ‘465.00’,


‘category’: ‘smart phone’,

‘variant’: ’64gb’,

‘quantity’: 1,

‘coupon’: ‘ ‘//Optional fields can be omitted or set to empty string. 



‘name’: ‘iPhone8’,

‘id’: ‘a12346’

‘price’: ‘365.00’,

‘brand’: ‘Apple’,

‘category’: ‘smart phone’,

‘variant’: ’32gb’,

‘quantity’: 1,

‘coupon’: ‘Buy2’






You may notice that for measuring product information you have to include product name or product ID. It’s always wise to include both. If you don’t capture product name you will see (not set) in the product column of your Google Analytics ecommerce reports. Similarly, by not including Product ID the product list attribution won’t work.

Where to place the Enhanced Ecommerce datalayer push?

This depends upon whether the user is redirected to a ‘Thank you’ page or if they remain on the same page. If they are redirected to another page the code should be placed above the GTM script on the page so that the transaction data will be accessible to GTM when the ‘Thank you’ page loads. This means the ecommerce data will be sent at the same time as the Pageview event.

When the user is not redirected to another page when the transaction is successfully completed the developer can choose where to place the code. However, they will need to ensure they include an ‘Event’ parameter to confirm the payment has been successful.

3. Create GTM Trigger:

Login to your GTM container and go to ‘Triggers’ > ‘New’ and call your trigger ‘Custom – Transaction’ or something relevant to the type of activity you are tracking.

For the trigger type select ‘Custom Event’ as we have defined an ‘event’ in the datalayer.

‘Event name’ use the exact same wording as used in the script and so in this case we use ‘transaction’.

Provided we only have ‘transaction’ events appearing on a single page we can use the default setting of ‘All Custom Events’.

Trigger for Custom Event - Transaction

4. Create a Tag:

Go to Tags > New and call it ‘GA Event – EEC’ and select the following options:

Tag type: Google Analytics Universal Analytics

Category: Enhanced ecommerce

Action: [(Event)}

Label: {(Page Path)}

Non-Interaction Hit: True

GA Settings: Standard GA Settings

Enhanced Ecommerce Tag

You can now select the trigger you have just set up called ‘Custom – Transaction’. If you have other enhanced ecommerce triggers for different events you can add those to this tag as well to minimise the number of tags you need to create. Now save the tag.

5. GA Settings Variable:

Now go to ‘Variables’ and the GA Settings Variable. Click to edit and select the menu item ‘Ecommerce’ below Custom Dimensions.

Now check the box for ‘Enable Enhanced Ecommerce Features’ and also check the box ‘Use Data Layer’. Then save the changes before leaving the variable.

6. Test, test and test:

In GTM click on ‘Preview’ mode’ to allow you to bring up the Google Tag Assistant widget on your website. I have written a blog post on how to use the new GTM Preview mode if you have any questions.

Go to the tab with your website and go through the transaction journey and check the ‘Transaction’ event fires on the page where the code has been placed. You should also check the ‘Realtime’ tab of your Google Analytics property to check the data is being captured under events.

I normally test in Dev or UAT so that I can be sure the code is working before it goes into production. You can do this by setting up separate Google Analytics properties for each environment. Then use a Lookup table in GTM to determine which property is sent data from each environment.


Enhanced ecommerce tracking is a great way to enrich the data you collect in Google Analytics and implementation is often not as complex as you might think.

Begin by going to your Google Analytics property to enable enhanced ecommerce in the settings tab.

If your site is on a popular platform such as WordPress and are using a plugin like Woocommerce you will have a built-in datalayer. However, if not, you may have to implement a datalayer with the help of a developer. Ensure you use the correct Google syntax and test implementation in a non-production environment.

Create your GTM triggers to fire on the relevant events and then set up a new tag. You should be able to use the same tag for all your ecommerce events.

Finally, ensure you test using GTM’s ‘Preview’ mode to check the events fire as they should. Use GTM to send data to your Dev or UAT environments so that you can also check data is being captured in Google Analytics. Once everything is working you can also build custom segments in Google Analtyics using your ecommerce events to accurately measure your conversion rate at each step in the funnel.

More reading

How is Coronavirus Changing Digital Marketing?

A Guide To Cross-Domain Tracking in Google Analytics


Leave a Reply

Your email address will not be published. Required fields are marked *