Cream Whipped Airplane
Cream Whipped Airplane

Reputation: 1367

How to replicate 'Google Analytics Settings' variable in GA4 tag setup?

With UA it is possible to declare a variable of type 'Google Analytics Settings' and in this variable we can set the GA container ID + all fields we want to set + all custom dimensions we want to set. This allow us to do this configuration only once, and then any tag that uses this configuration always sets these global fields and dimensions. This is for example useful for pushing the user ID.

With GA4 this variable type doesn't seem to be supported. We are only allowed to use Tags and on each Tag the GA4 container ID needs to be set individually as well as all the fields and custom dimensions. This means that for every tag that we have we need to remember to set all fields and dimensions each time.

I have over 100 Tags in GTM that I am converting to GA4 and this is becoming a real pain. I can already see the issues with maintanance as there is no single source for this configuration and if I later decide I want to add a new custom dimension I will have to add it to all 100 fields, where in UA I could have justed edited the variable and it affected all the 100 tags automatically.

Am I missing something? Is there any way to set global custom dimensions and fields in GTM when working with GA4 container?

UA variable configuration allowing for global fields and dimensions: enter image description here

GA4 tag configuration requiring individual fields config per tag enter image description here

Upvotes: 2

Views: 2406

Answers (1)

ptts
ptts

Reputation: 2086

I have been using the GTM Google Analytics: GA4 Configuration tag to set values that persist during the lifetime of the pageload, re-executing it whenever a global parameter changes.

In order to not send multiple page_view events, you need to disable page view tracking in the config tag and create a separate page_view event tag.

enter image description here

Google writes:

By updating the config command in the global site tag, you can set parameter values for every event on a page. For example, to change the page title, add the page_title parameter to your config command.

This should be what's happening in the background when calling the GTM Config Tag.

If you want the global fields to also affect other Measurement IDs, you can call gtag.set:

If you configure multiple properties on a page, use the set command so that all measurement IDs inherit the properties. Place the set command above the config command so the values are passed with pageviews.

gtag('set', {
  'random_session_id': '143b9fda',
});

You might have use a Custom HTML Tag for this and set it as a Setup Tag for the GA4 Config Tag.

(Ref.: https://support.google.com/analytics/answer/11396839?hl=en)

Upvotes: 3

Related Questions