I'm trying to follow this guide: https://developers.google.com/gtagjs/reference/api#set
It says that you can use gtag('set', {key: value})
to add a set of values to the next gtag
calls.
However, it doesn't work.
So, this is the setup I used in order to have gtag
available on the app:
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('set', 'anonymizeIp', true);
gtag('config', 'my_ga_tracking_id', {
send_page_view: false,
custom_map: {
dimension1: 'a_dimension'
}
});
And then this code once the app is loaded:
gtag('set', { a_dimension: 'test' });
gtag('event', 'an_event');
I expected to see the a_dimension
attached to the event an_event
sent to GA but I can't find it.
What am I missing?