This is a short guide for everyone who wants to set up an event in Google Analytics 4 using Tag Manager. This isn't an advanced guide on how to track complex events on your website, but it's very helpful for all PMs who want to track basic events without utilizing technical resources.
No data layer, no server-side tagging, just plain event tracking. Our goal here is to help you dive into the tag manager realm with the simplest tracking concept available in Tag Manager.
Before we proceed let’s explain what Tag manager is and why we need it:
Tag Manager serves as a bridge, enabling you to seamlessly integrate and manage tracking codes (tags) on your website without continuously modifying the website's code. It's crucial because it offers flexibility in tracking and analyzing vital user interactions without intensive coding or development.
I'll guide you step by step, providing explanations and details for each step. The objective of this guide is to create a goal in GA every time a user clicks on the “Subscribe” button.
Open Google Tag Manager
Go to https://tagmanager.google.com/ and create your account.
Create your account
Navigate to your account and select “Create your account”. If you have a pending invitation, it will appear at the top, just like the one shown in the screenshot below.
In the setup process, you'll need to input a name, choose a country, and specify the setup type. I selected “web” since I'm tracking an event on my website.
Make sure you agree to the terms and conditions before creating your account. Once your account is set up, you'll see the following screen:
Install tag manager in your website
Click on “Admin”, and a settings screen will appear.
Next, select “Install Google Tag Manager” and follow the installation guidelines. Here's a useful link. Installing Tag Manager can vary depending on the CMS of your website. Generally, it's straightforward, but you might require some technical assistance for this step.
Add Google tag
You must set up the Google tag before proceeding. Go back to “Workspace” and locate “Tags” in the left-hand menu. Here's the tag's entry page:
Move to “Tag Configuration”, and you'll encounter various tag types. Click on Google Analytics, and a screen will pop up guiding you to utilize the Google tag and GA4 event to activate measurement for GA4. Opt for the Google Tag.
Within the Google tag, input the tag details of your Google Analytics. There are detailed instructions on where to locate it. However, if you face any difficulties, use this path in Google Analytics:
Open GA → Go to Admin → Navigate to Property → Open Data Streams → Access Stream Details → Copy Measurement ID.
Retain the default trigger settings, which is - Initialization on All pages.
Save your changes and return to your workspace.
Make your first submit
Click on “Submit” in the top right corner and publish your initial changes. Describe the changes you've implemented on the subsequent page for efficient versioning.
Click “Publish” and “sing like no one is listening”.
Inspect the website
Prior to setting our triggers, we must inspect our website to discern what we can track and how to go about it. Return to the workspace and select “Preview” on the top right. Enter the URL of your website when prompted, then click connect.
A new window will showcase the website you provided along with a message regarding the tag manager connection. If your tag manager isn't connected, revisit and double-check your installation.
You will also see the following screen which includes all the data you can utilize for your tracking. As you can see my Google tag fired properly and I can see that in tags section.
Every action you undertake on your website's window will generate additional activities on this page. For instance, if I navigate to a page, a “click” action will be recorded, encapsulating all associated data from that click. For our intent, we'll focus on the variables section.
Here we can see all the variables captured. It seems that I clicked a button that had text “biography”. There are a lot of variables that you can utilize but for our example you can stick to the basic ones that are built-in and don’t require additional technical development.
As a disclaimer here, tracking an event by using the text on it is bad practice. It’s not recommended because, there might be other buttons that include the same text and the text might change in the future, so you are going to lose the tracking. Tracking clicks based on click-id is better, but for our example, we’ll stick to text. But for a beginner, this is the first step to understand how Tag manager works.
Next, proceed to select the button you wish to track, in this instance, the “subscribe” button. After clicking, you'll observe the following variables:
I can see here that the click text “subscribe” exists in my button so I’m going to use it in Tag manager.
Setup the trigger
Navigate to “triggers” and click “New”.
Provide a name for your trigger, like “click_subscribe” for the subscribe button clicks. Within trigger configuration, you'll encounter various trigger types.
More often than not, I opt for click → All elements or just links. You'll then need to specify which click to track. Select “some clicks” and use the Click Text you identified during the inspection.
By saving, you've now established your first trigger. Although using click text isn't the best approach, for the sake of simplicity in this tutorial, we'll continue with it.
Setup the tag
Now, let's configure the tag. Return to the tags section and add a new one. During the configuration, choose “Google Analytics” followed by “Google Analytics: GA4 event”.
Use a consistent naming pattern for your tag, such as “GA_click_subscribe”.
Enter the same Measurement ID you used earlier and define your event name. Again, employ a naming convention that aligns with your requirements. I've opted for “click_subscribe” as the event name.
A note here, if you don’t want to measure every hit on a button, you should go to advanced setting and check the available firing options. In my case, I want to measure it once per page, so I will set the right option from the list.
Next, we need to add the triggering. Click on the tab and you will see all your available triggers:
Use the “click_subscribe”, the trigger you created for this purpose. Now you have a proper tag in place that contains all the necessary information.
QA
Before advancing to GA to configure our goal, we need to validate if the tag operates correctly. Revisit the workspace and click “Preview”. We should notice our newly-added tag, though it hasn't been “fired” yet.
To “fire” it, execute the action that corresponds to its trigger. For this guide, that means clicking the “subscribe” button on our website. If it successfully fires, you're set to move on.
It fired so we are good to go.
Create GA4 goal
Now, let's fashion our goal in GA4. Open Google Analytics → Admin → Property → Conversions and click “new conversion event”. Enter the event name precisely as you did in Tag Manager and designate it as a conversion.
Live QA
As GA4 requires some time to disseminate our data, I frequently examine event tracking via the live preview of GA4. Navigate to Analytics → Home → View Realtime → Event Count by Event Name (screen) or Conversions by Event Name.
In conclusion, we've successfully crafted our initial tracking event in GA4 independently. This process can be replicated for other functionalities like a “click to call” CTA, or delve into the Tag Manager documentation to establish tracking for additional elements such as IDs, scroll depths, URLs, or even conversion funnels.
Happy tracking!
Other relevant posts: