Naturally, there are a few different ways to track events on your site. However, when it comes to custom event tracking, nothing rivals the unprecedented power of creating custom events in Google Analytics 4 (GA4) using Google Tag Manager.
In this article, we’re going to go through the steps on how you can create and deploy your first custom event in GA4 using GTM.
Before we get started, here’s a brief overview of the steps involved. If you would like to jump ahead to a certain section, click on one of the bulleted points listed below.
- Find your measurement ID
- Configure Your GA4 tag in GTM
- Set Up Variables
- Set Up Triggers
- Configure the Tags
Creating a Custom Event in GA4 using Google Tag Manager
First things first, we need to set up our Google Analytics 4 tag in the Google Tag Manager container to ensure that our event tracking is connected to the correct GA4 property and populates data accordingly. For this example, we will be focusing on tracking a specific website click on our website that isn’t automatically defined by Google within our GA4 property. We want to be able to track each time a user clicks our contact number. It looks like this:
#1 – Find Your Measurement ID
The first thing we’re going to want to do is connect our Google Analytics 4 property and our Google Tag Manager container. In your GA4 property, select the “Data Streams” option under your property options in the “Admin” tab.
Click on the GA4 data stream for your domain. Thereafter, you should find your GA4 property’s Measurement ID. Copy and paste this into your GA4 Tag Configuration in Google Tag Manager.
#2 – Configure Your GA4 Tag in GTM
Prior to creating our custom event tag, we first need to configure our GA4 tag in Google Tag Manager to connect the two applications.
In your GTM container, create a new tag by following the below steps:
- Click “New Tag”
- Label your new GA4 Configuration Tag
- Choose the “Google Analytics: GA4 Configuration”
- Input your Measurement ID
- Check the “Send a page view event when this configuration loads”
- Click save
Now that our GA4 tag is configured, now we need to set up our custom event’s variables, triggers, and tags.
#3 – Set Up Variables
Naturally, there are two types of variables: built-in and user-defined variables.
There is an array of built-in variables to choose from, but for the purpose of this example, we want to enable the click variable.
In your Google Tag Manager, click the “Configure” button in the top right corner of the Built-In variables section in the variables tab, and select all the checkboxes under “Clicks”.
#4 – Set Up Triggers
The custom event trigger is used to track certain interactions that occur on websites in GTM. For this example, when the element on a page that matches the trigger conditions, Google Tag Manager will automatically populate values for any active click-based built-in variables.
To create a new custom event trigger in Google Tag Manager:
- Click “Triggers” on the left side menu and then click “New”
- Click “Trigger Configuration” and select “Just Links”
- Configure the conditions which need to be true in order for this event to fire this trigger; in this case it’s going to be when URL clicked matches the regular expression of ‘tel:’
Here’s what our configured Trigger looks like.