GBS
GBS

Reputation: 154

GA4 - gtag set behaviour

Using GA we could set dimensions using set:

ga ('set', 'ua_dimension1', 'dimensionValue');

And this dimensions would be applied to the rest of the calls.

But using GA4's set like this:

gtag('set', {'ua_dimension1': 'dimensionValue'});

It does nothing, and the dimension isn't added to the rest of the calls...

When I set the dimension using config it does work:

gtag ('config', 'GA4_KEY', { 'ua_dimension1', 'dimensionValue' });

But it overrides all previous parameters that i setted to config before... Is there a way to set dimensions using config without overriding the previous config calls?

What im missing? In the official docs they say that set has to work as it does before, but it isn't.

I already registered this dimensions on my GA4 account, and waited 24 hours.

Upvotes: 0

Views: 542

Answers (1)

BNazaruk
BNazaruk

Reputation: 8081

Yes, gtag is not ga. Analytics.js used to be a great library with a lot of useful functionality. Gtag is missing that complexity, instead, it's capable of doing a wide range of things unrelated to Google Analytics.

Read this on the set problem: Google Analytics custom dimension not working: gtag set() method issues

You either set the dimension with the config, or you set them in events. Or, of course, you stop using gtag.js directly and use it via GTM as per best practices.

Upvotes: 0

Related Questions