Close
Menu
  1. Scrapbook
  2. How to track events in GA4 using Google Tag Manager
How to track events in GA4 using Google Tag Manager

How to track events in GA4 using Google Tag Manager

How to track website events in GA4

Google Analytics 4 (GA4) allows you to track events on your website or mobile app. Events are actions taken by visitors such as clicking on a link, submitting a form, or making a purchase. As we have previously discussed, some events require additional code to be added into your site and some don’t. Tracking events can help you gain valuable insights into user behaviour and improve the user experience of your website or app. 

In this article, we will discuss how to set up tracking for events in Google Analytics 4 that do require additional code – and some of the best practices for doing so. We will also look at some use cases for tracking events with GA4 and how it can help you make better decisions about your website or app.

Tracking recommended events

One of the benefits of Google Analytics was Enhanced E-commerce, a set of dimensions, metrics, and reports, which provide you with insights into how users are interacting with your products on your e-commerce site. However, this has been difficult to implement, and when it comes to lead generation, does not exist, so you were unable to gain a full picture of your website funnel. 

The Data Layer

Google recommends implementing these events through the Data Layer, the ‘virtual layer’ between your website (code and server) and tag management system (GTM) where data is stored, passed, and processed.

With GA4, these listed events can be implemented into your Data Layer for beyond e-commerce events, for example, the ‘select_item’ event could be fired when a user selects a product or service page from a list.

Example: select_item tracking

Continuing with the ‘select_item’ example, you wish to track the moment a user clicks to view your product or service page from a list.

First, you need a developer to activate the following dataLayer.push code when a user selects an item from the list.

DataLayer implementation example

This event is sent by pushing a select item object. Measure selection by using the select_item action.
To be installed on every page a product is listed. 

GTM set up 

You can load the data directly from the dataLayer by following the GA4 schema. You will need to populate the parameters manually by creating Data Layer variables.

Create Data Layer variables 

The data layer variable enables you to collect values from the Data Layer and turn them into variables that can be used in your Tags, Triggers, or other variables. By default, GTM does not recognise custom data, you will need to create a variable to specify the Data Layer value you want to retrieve. 

  1. E-commerce Items

In the case of this example, where a user selects an item from a list, the following custom event trigger should be configured.

  • Variable: DLV – Ecommerce Items
  • Data Layer Variable Name: ecommerce.items

 

2. E-commerce Item List ID

How to track events in GA4 full guide

  • Variable: DLV – Ecommerce Item List ID
  • Data Layer Variable Name: ecommerce.item_list_id

3. Ecommerce Item List Name

  • Variable: DLV – Ecommerce Item List Name
  • Data Layer Variable Name: ecommerce.item_list_name
Configure the Trigger

A trigger listens to your website for certain types of events, such as form submissions, button clicks or page views. The trigger tells the tag to fire when a specific event is identified. 

In the case of this example, where a user selects an item from a list, the following custom event trigger should be configured.

  • Trigger Type: Custom Event
  • Event Name: select_item
  • This trigger fires on: All Custom Events

Configure the Tag

A tag is code that sends data to your web analytics service, for example Google Analytics.
In the case of this example, where a user selects an item from a list, the following GA4 event trigger should be configured.

  • Configuration Tag: GA4 configuration
  • Event Name: select_item
  • Event Parameters (Parameter Name – Value):
    • items – {{DLV – Ecommerce Items}}
    • item_list_id – {{DLV – Ecommerce Item List ID}}
    • item_list_name – {{DLV – Ecommerce Item List Name}}
  • Triggering: select_item custom event

The benefits of tracking events

With the ‘Explorations’ feature in GA4, you can create reports using various data visualisations and analysis techniques. A feature similar to this has only been available for paid Universal Analytics users of Google Analytics 360. 

A similar feature was available in Universal Analytics for paid Google Analytics 360 users. With Google Analytics 4, it’s available for free as a built-in feature.

These ‘Explorations’ can take your content, research, and CRO to the next level; as you can deep dive into the journey your users take on your site to convert, be that a purchase or to enquire.

Start tracking the events that matter to you, today.

At Door4, we’re on hand to make your transition to GA4 as simple and stress-free as possible. So, if you need any help or advice on setting up events and conversions in GA4, or ensuring your setup is correct and measuring accurately, start the conversation today.

Scrapbook

We have a lot to talk about.

Door4 opinions and insight - exploring performance marketing, communications and optimisation.

Book a situational analysis

BENCHMARK where you are, EVALUATE what is required to achieve your commercial goals, and outline the PLAN of action to get you on track.

Proud to work with

Ready to discuss your growth plans?

It's time to work with a results-driven agency that will help you exceed your goals.
Find out how we work, and get in touch to arrange the next steps.