Setting up e-commerce events and tags in Google Tag Manager

Google Tag Manager (GTM) is a tag management system that allows you to quickly and easily update measurement codes and related code fragments collectively known as tags on your website or mobile app. Once the small segment of Tag Manager code has been added to your project, you can safely and easily deploy analytics and measurement tag configurations from a web-based user interface.

The first step of configuring e-commerce Events in Google Tag Manager is sharing your GTM snippet with the AnyRoad team to add to your account.

Once that step is completed, follow the instructions below to set up Google Tag Manager and start receiving e-commerce events, as well as the relevant transactional details, in your brand's Google Analytics Dashboard.

Adding New Triggers for Viewing Details, Checkout, and Purchase Events

Tags fire in response to events. In Google Tag Manager, a trigger listens to your web page or mobile app for certain types of events like form submissions, button clicks, or page views. The trigger tells the tag to fire when the specified event is detected. Every tag must have at least one trigger in order to activate it.

In the Triggers section, you need to create 3 different triggers for the respective custom events that AnyRoad uses, the detail, the checkout, and the purchase event. The triggers are used to fire the tag to the dataLayer.

Here are the instructions to create the detail trigger. In order to create the rest of the triggers, just replace the word "detail" with "checkout" or "purchase" depending on which trigger you are creating each time.

  1. Go to Google Tag Manager and select the account you would like to work with or create a new one

  2. If you select to create a new account then fill in all the required details and as a platform select Web

  3. Navigate in the Triggers tab

  4. Click on the New button in the upper right corner to create a new trigger.
  5. Click on Untitled Trigger and write "detail"
  6. The trigger type should be Custom Event

  7. The Event name needs to match the trigger name, in this case, it should be "detail"

  8. The Use regex matching needs to be unticked and the trigger should fire on All Custom Events
  9. Follow the same instructions for checkout and purchase triggers.
  10. After creating all three triggers, the triggers tab should be as follows

Adding the variables

Variables in Google Tag Manager are named placeholders for values that are populated when code is run on your website or mobile app. For example, the Tag Manager variable named Page URL returns the current web page URL.

To create a variable, follow the below steps:

  1. Click on the Variables tab

  2. Then to create a new variable click on the New button in the User-Defined Variables

  3. The first variable is the Universal Analytics ID. This variable will be added each time we need to write the UA-ID. Name the variable “Universal Analytic” by clicking on the Untitled Variable

  4. Then click on the Variable Configuration and select the Constant option in the Utilities section

  5. In the Value field add the UA-ID from the Google Analytics account

  6. Click Save

  7. Create a variable called “Google Analytics Settings”. This variable will carry the tag settings on each tag. In the Variable Type select Google Analytics Settings under the Utilities section

  8. In the Tracking ID add Universal Analytics

  9. Cookie domain should be set to auto

  10. In the More Settings, open the Ecommerce option and enable the Enhanced Ecommerce Features and the data layer

  11. Create a variable called "GA - e-commerce" and set it up as a Data Layer Variable in the Page Variables section. This is for creating a variable in the data layer that will get the e-commerce value of revenue

  12. The Data Layer Variable Name should be ecommerce

  13. The Data Layer Version needs to be Version 2

  14. Click Save

  15. Create a variable called "DLV - ecommerce - revenue" and set it up as a Data Layer Variable in the Page Variables section. This adds the revenue variable in the data layer

  16. The Data Layer Variable Name is ecommerce.purchase.actionField.revenue

  17. The Data Layer Value has to be Version 2

  18. Save the variable
  19. The Variables should look like the following screenshot

Creating the Tags and associating them with the Triggers

We need to create 4 different tags, three for the distinct custom events (detail, checkout, purchase) and one for the page views.

  • The detail tag is triggered when they visit the live page of an experience

  • The checkout tag will trigger once they visit the checkout page

  • The purchase tag fires after completing the checkout process and before seeing the booking confirmation screen

To create a new tag, follow the steps below:

  1. Navigate to the Tags tab
  2. Click on New
  3. Click on the Untitled tag and type "detail tag"

  4. Click on the Tag Configuration box

  5. In the Tag type menu, select Google Analytics: Universal Analytics

  6. In the Track Type, select Event

  7. In the Category, type "e-commerce"

  8. In the Action field, type "detail"

  9. The recommended setting for the Label field is "{{Page URL}}" which you can either type or select by pressing the Variables button on the right of the field.

  10. The Non-Interaction Hit should be set to True
  11. In the Google Analytics Settings, select the {{Google Analytics}} variable

  12. Click on the Triggering box further down

  13. From the trigger menu, select the detail trigger

  14. Click Save in the upper right corner

  15. Follow the same steps to create the checkout tag except:
    1. in step 3 the Name should be "checkout tag",
    2. in step 8 the Action should be "checkout" and
    3. in step 13 you need to select the checkout trigger.
  16. For the purchase tag follow all the above steps and
    1. in the Value field either type "{{DLV - e-commerce -revenue}}" or select it from the variables list
    2. Tick the Enable overriding settings in this tag
    3. Expand the More Settings menu
    4. Expand the Fields to Set menu
    5. Click on the + Add Field button
    6. In the Field Name type "transport" and in the Value field type "beacon"
    7. in step 13 select the purchase trigger
  17. For the all pages tag:
    1. the name of the tag in step 3 should be “all pages tag”
    2. the Track type in step 6 should be Page View
    3. the trigger in step should be All pages
  18. In the end, the tag tab should look like this:

If you have any additional questions, you can contact our Customer Experience team at

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.