Get Started with GTM for GA4

2022-08-26 | Fact sheet | Insights


Everybody knows that Google Analytics 4 (GA4) is replacing Universal Analytics (UA) in the upcoming months. But the big question now is, how should we get prepared with GA4, how to implement it and what's going to change in the Google Tag Manager (GTM) implementation?

With Universal Analytics in the market for the past few years, the level of maturity of its usage was quite high. Anyone knows how to implement a Pageview, an Event, or an Enhanced Ecommerce tag on GTM. Well, at least most of the analytics consultants know how to do it. Now that GA4 was imposed on us, we don't have many alternatives left but make the best use of it. With this short overview being said, the big question is: How can we get up-to-date in terms of GTM implementation when the topic is GA4?

Comparison between UA and GA4

Before opening the GTM, a quick comparison between GA4 and UA is required. Universal Analytics used to have only one tag template on GTM, where we could drop down its many different applications, like Pageview, Event, Transaction, Social, Time, Decorating Link and Decorate Form, like the screenshot below:

Now for GA4 we have two different tags: GA4 Configuration and GA4 Event. GA4 Configuration is the tag required to insert your Measurement ID and add your Custom Dimensions, User Properties and other Advanced Settings. What you used to do on your Google Analytics Settings Variable is now done via the tag GA4 Configuration. Anything else is now done via the tag GA4 Event. Events, Transactions, Engagement Events, etc, are now called in GA4 "Events". Everything is Events. It can be misleading initially, but with time we realize that this new data structure makes way more sense. When you look at one relational database you can visually organize it with rows and columns. Let's say the first column is the field "Event Name" and every new row is a new hit. Looking for the values of the first column you can see different hit types, like "page_view", "menu_navigation", "Purchase", etc. Everything is now Event oriented, but of course, you have the column "Event name" helping you to identify what kind of hit GA4 is receiving:

The other columns of the database? Some of them are automatically added and others are manually added (Custom Dimensions). Using the Event Name "page_view" as an example. Automatically GA4 adds some Parameters (columns), such as: "page_location", "page_referrer", "page_title", etc. What if you would like to add a new Parameter called "page_type", in order to know if this Event "page_view" is part of the HomePage, ResultList or ProductPage? Here is when the fun starts!

How to implement GA4 with GTM

Let's move now to the GTM interface and take a deeper look over the tags and its functionalities. After creating a GA4 account we need to create a Data Stream, where we can decide if the data source will be "Web", "Android" or "iOS". Due to the created data stream we have now a Measurement ID. You can simply copy it from the Admin area on GA4 and paste it on your new GTM tag "GA4 Configuration" (please see screenshot 3 &4 below).

On this same tag you can select the box "Send a page view event when this configuration loads", so every time GTM loads this tag (that should be triggered in “All Pages“), an Event called "page_view" will be fired, containing its automatic Parameters mentioned previously. Name your Tag, create the right Trigger, add the Measurement ID, and, Voilà, you have your website firing Pageviews every time one page is loaded. Not that hard, right?


Now the next step is implementing Events. Forget about Category, Action and Label. GA4 now it's structured with Event Name + Event Parameters. Below you can see one example for implementing events in UA and now for GA4. Eg: Event when the User clicks on the menu navigation Universal Analytics: Category: "menu_navigation_header" Action: "1st_level_menu_shoes" Label: "2nd_level_menu_black_shoes" Custom Dimension (page_type): "home_page"


Event Name: "menu_navigation_header"
New Parameter (Type: Event) (1st_level_menu): "shoes"
New Parameter (Type: Event) (2nd_level_menu): "black_shoes"
New Parameter (Type: Event) (page_type): "home_page"
It makes sense, right? Now every Event fired from your website should be implemented under this structure. DataLayer push triggering Generic Events tag Creating one single genericEvent tag in GTM can be really helpful when you already have your dataLayer pushes being sent from your backend. Every dataLayer push should contain the structure below:
'event': 'generic_event',
'event_name': 'menu_navigation_header',
'parameter_name_1(Eg:1st_level_menu)': 'shoes',
'parameter_name_2(Eg:2nd_level_menu)': 'black_shoes',
'parameter_name_3(Eg:page_type)': 'home_page'
One GTM variable type "Data Layer Variable" should be created to receive the values independently, like the example below: "event_name"

...and so on... Now we have to create one GA4 Event tag to be triggered when the dataLayer push "'event': 'genericEvent'" is fired. When we have one tag per event, the values are fixed. That's not what we want here. Now it's time to make everything dynamic, so it doesn't matter which event is fired via dataLayer push, the same tag will always send the event to GA4, automatically adapting its values with the variables received via dataLayer structure. We can see the example below:

We can see that instead of having fixed values, every Parameter receives a variable. For every dataLayer push value, the tag will adapt the value and send it dynamically. The Trigger created will activate the tag every time the dataLayer push contains "'event': 'genericEvent'" as we can see below:

With all the dataLayers positioned correctly on your website, GTM will be prepared to receive all the variables, the values and fire them to GA4, where it will be collected and reported. Keep in mind all of these GA4 events can be used as goals and audiences when integrating GA4 with other Marketing Tools.

Define a tracking strategy

Before starting, it’s always important to create a digital strategy, in order to implement the necessary and most requested information from your User navigation. If you create one event with a certain name, then over the months/years you decide to change this name, it will be counted as another event, so when you just create events randomly, not having a clear purpose, or not following the naming/structure patterns, you can cause more damage than value, when within years you will have unstructured data on your Analytics tool. So spend more time defining your strategy than implementing it. Measure twice, cut once.

Other GTM/GA4 functionalities

Of course, Pageview and Events are an important part of a GA4 implementation, but that’s not all. We still have topics like: EEC User Properties Consent Mode Cross Domain PIIs removal And more… For these other topics, we will have to split in different articles that are coming in the upcoming days. Stay tuned and good luck with your new GA4 implementation!

Are you interested?

Contact us