The easiest way to implement Google Analytics 4 is through Google Tag Manager. Placing the gtag.js script on your page and enabling Enhanced Measurements is no challenge either, but it still does not offer you the flexibility that Google Tag Manager can.

6 Professional Implementation Tips for GA4 in GTM

With a plethora of great online tutorials online on implementing Google Analytics 4 in Google Tag Manager, I want to do something different. I want to take the time and share some professional implementation tips with you to help you save time and get high-quality data into Google Analytics 4 from day one.

ℹ Did you know that Google Analytics 4 works perfectly with Google Tag Manager Server Side? Read more.

1. Use existing Triggers and Variables

Whenever I start a new tag management project, I will always start with an audit if there is an existing implementation. An audit of Google Tag Manager will reveal the quality of the existing implementation and help me answer one simple question:

Can I implement Google Analytics 4 using existing Triggers and Variables?

The answer is Yes, absolutely. There are two major benefits to reusing existing triggers:

  1. you save time creating triggers and variables from scratch
  2. you can pass on GDPR or CCPA safe triggers to your Google Analytics 4 tags

In a previous article, I discussed when you should implement Google Analytics 4. Implementing Google Analytics 4 in parallel to Google Analytics Universal is the consensus in the digital analytics industry. One of the reasons is that it will allow you to perform proper quality control of the data quality before migrating your business’ data dependency from one version to the other. A parallel implementation of Google Analytics 4 and Universal Analytics will enable you to compare your new implementation to the old on the data level as much as the technical level. By reusing existing triggers and variables, you can (nearly) ensure that duplicate data payloads are sent to Google Analytics 4 and Universal Analytics. This will help detect and trend differences caused by the new event-based data model and prepare your stakeholders to explain them.

Never forget, though, that since both underlying data models are different, data can differ.

2. Use the Template Gallery

This is also a golden tip. In the early days of Google Analytics 4, when Google announced the capability of tracking e-commerce data, I ran into a little issue. Any company taking data collection seriously will implement a data layer. According to Google’s own support pages, a data layer is defined as:

A data layer is a JavaScript object that is used to pass information from your website to your Tag Manager container. You can then use that information to populate variables and activate triggers in your tag configurations.

Now, without getting into the data layer’s technical aspects, I want to clarify that when implementing Google Analytics 4 through Google Tag Manager, changes to the data layer are inevitable. This is ever more so the case with the Ecommerce object.

enhanced ecommere datalayer product view ua

Example of the data layer for tracking a product detail page. (Source: Google)

enhanced ecommere datalayer product view ga4

Example of the data layer for tracking a product detail page. (Source: Google)

As you can see, the Ecommerce object is structured differently. Regardless of the power of data layers, the only downside is that it requires a developer to change its content and structure.

If you have a default Enhanced Ecommerce implementation for Universal Analytics, there is a solution in the form of a Google Tag Manager Template Variable. In this case, you can create a new variable in Google Tag Manager, search the Template Gallery and select the GA Enhanced Ecommerce to GA4 Ecommerce Converter variable. Assign it the variable used to lift out the existing eCommerce object itself, then assign the new variable to your Google Analytics 4 Configuration tag.

Google Tag Manager Template Gallery example

3. Reuse existing Universal Analytics event data

As inviting and potentially easy as it sounds, reusing existing Universal Analytics events can be tricky if not properly thought out. With Google Analytics 4 new event-based data model, the old Category > Action > Label hierarchy has become deprecated. To still use old Universal Analytics events, you will need to consider how you want to reuse data currently being sent in events.

Google Analytics 4 event parameters setup

Simply assign extra parameters to Google Analytics 4 events using Event Parameter fields.

Most importantly, it needs to be pointed out that Google has set aside guidelines for assigning and using events in Google Analytics 4. There are 3 types of events available:

  • Automatically collected events
  • Recommended events
  • Custom events

It goes without saying that when you plan to reuse existing Universal Analytics events, I recommend checking the guidelines before simply remapping values. Also, involve your web analyst in the process since they will be using the data to create insights.

Some would consider mapping the Event Category to the Event Name field a good choice. Since some event names are reserved, it would not be wise to take this route. An additional problem with that is that in Google Analytics 4 event names need to adhere to a specific format. Event names cannot contain any spaces, and it is best to force all values to lowercase. Although the latter can be accomplished using Google Tag Manager, the former cannot.

In all cases, I would recommend taking time to evaluate your approach, especially when it involves pre-defined events that use reserved names. Nevertheless, if you only want to test Google Analytics 4 a simple solution would be to create a GA4 event with the name universal_event then map the respective Universal Analytics values to the custom GA4 event parameters event_category, event_action, and event_label.

4. IP Anonymization is standard

The easiest tip of them all, and one I wish I knew before spending time trying to find out how to do it. If you are regionally bound by GDPR or CCPA laws, you know that IP addresses will need to be anonymized to be compliant. Google’s definition of IP anonymization is to remove the original 4th set of numbers from an IP address. This reduces the probability of pinpointing a user’s exact geo-location significantly.

For Universal Analytics, enabling the Fields to Set option in Google Tag Manager, add anoymizeIp, and set the value to true. You can do this in any Universal Analytics tag and the Google Analytics Settings variable (recommended).

anonymizeIp in Google Tag Manager
In Google Analytics 4, however, IP anonymization is switched on by default. You do not need to change any additional settings to enable it. Something good to know is that when you consider starting using Google Tag Manager Server Side, you will have the option to collect full IP addresses if user consent allows it.

5. Dynamically set Advertising Features or Advertising Personalization

Another important element concerning GDPR and CCPA compliance is the Advertising Features and Advertising Personalization settings. In Google Tag Manager, you have the ability to set these values dynamically matching a user’s given consent level. An important tip here is that the Fields to Set value is different for Universal Analytics and Google Analytics 4.

For Advertising Personalization, the following Fields to Set changes need to be made:

  • Universal Analytics: allowAdPersonalizationSignals
  • Google Analytics 4: allow_ad_personalization_signals

For Advertising Features, the following Fields to Set changes need to be made:

  • Universal Analytics: allowAdFeatures
  • Google Analytics 4: allow_google_signals

In the example below, a variable Cookie Marketing Check is used to determine if a user has given consent for remarketing/personalization purposes and translates it into a true or false value.

Dynamically disable Advertising Personalization GA4

Dynamically disable Advertising Personalization GA4

Dynamically disable Advertising Personalization UA

Dynamically disable Advertising Personalization UA.

6. Debugging Batch Events

My last tip is not necessarily a configuration tip but a debugging tip. A big difference between Universal Analytics and Google Analytics 4 is that Google Analytics sends data payloads in batches. What does ‘send in batches’ actually mean, though? When we compare with Universal Analytics, we can say that each data point, albeit a pageview or event, will send a single pixel request to Google. Google Analytics 4, on the other hand, bundles requests into batches.

The confusion is highlighted when debugging using common browser extensions. Most extensions don’t account for batch transmissions of events and will only highlight the first event in the payload. If you are unaware of this, it will drive you mad since you cannot explain why you don’t see the events in de extension, but data is still arriving in Google Analytics.

Google Tag Manager Debug Google Analytics 4 Network Activity

Monitor Google Analytics 4 network activity in the Javascript console of your browser. Filter activity on ‘collect?v=2’

Personally, I tend to debug using the following methods:

  1. visualize any tagging on a site immediately using Tagbird Google Chrome Extension
  2. use the new Tag Assistant available through Google Tag Manager preview mode to see which tags got triggered, why they got triggered, and what the contents were
  3. if you prefer, you can always use your browser Javascript console’s Network tab to filter out all hits. Filter for collect?v=2 to only see Google Analytics 4 hits.
  4. a little bonus because it displays batch events really well, use David Vallejo’s GTM/GA Debug Google Chrome Extension

Final Thoughts

When you start implementing Google Analytics 4 through Google Tag Manager yourself, I am confident you will run into more situations than I have described here. Even more so, if you use Google Tag Manager Server Side, some of these tips will need to be handled differently.

Even though implementing Google Analytics 4 may sound easy, the bottom line is that there are plenty of pitfalls you need to watch out for. Take it one step at a time, start sooner rather than later, and learn all you can. I am confident you can do it.

If you get stuck or need some help, please feel free to schedule a meeting with me using the button below or by contacting me through email.