I am trying to send some events to google analytics using gtag.js. I have added this code to the head section of the html: window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date());
gtag('config', 'MEASUREMENT_ID', {
'cookie_flags': 'SameSite=None;Secure',
'cookie_domain': 'https://subdomain2.subdomain1.force.com',
});
</script>
And in the code I am calling this function:
gtag("event", "dummy_test", {
event_category: "test_category",
event_label: "test_label",
value: 96,
});
But when the page loads, I am seeing this in the firefox (99.0.1) console:
Cookie “_ga_XXXXXXXXXX” has been rejected for invalid domain.
I am not seeing this message in the console if I am not setting the cookie_domain when I am configuring gtag. Is there a way to test this without creating another stream url in the google analytics?
I have also tries setting the cookies like this, but the behavior is the same:
gtag('set', {cookie_flags: 'SameSite=None;Secure'});
gtag('set', {'cookie_domain': 'https://subdomain2.subdomain1.force.com'});
gtag('config', 'XXXXXXXXX');
PS: I have disabled the adblocker and content tracking for localhost.