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?
question from:
https://stackoverflow.com/questions/65935187/gtag-set-is-not-attaching-data-as-expected 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…