react-gtm-module not posting events to GA4 in Chrome
devinwalter opened this issue · 2 comments
Chrome Version: 108.0.5359.124
Package Version: 2.0.11
Problem:
We seem to not be getting events passed in to GA on chromium based applications. In Firefox the GTM events get funneled to GA correctly, so it doesn't seem to be configuration on our end.
Our application is a Microsoft Teams based application, so is hosted through an iframe on their app, which we don't control that iframe, which also might be an issue, however again this works in firefox.
With GA Debug: ON we see the events trying to be pushed and then we get
Generated new client id: <redacted>
js?id=G-57Z8TEKTRK&l=dataLayer&cx=c:180 No session cookie found. Generating fresh session object.
js?id=G-57Z8TEKTRK&l=dataLayer&cx=c:180 Event processing aborted during storage.
As well as warnings saying GA couldn't update the session cookies. This seems to be only affecting chromium based browsers as far as we can tell, but since Teams uses Chromium based on Mac, we are also not seeing it in client.
Any thoughts?
@devinwalter I'm not sure if it's the same issue, but I had issue where the session cookies were failing to set because of the samesite
policy which I encountered with my project that's in an iFrame and hosted on a third party domain.
My workaround was setting the following on the GA4 configuration Tag in GTM as "Fields To Set":
Field Name: cookie_flags
Field Values: samesite=none;secure
This package has no means to set the cookie flags because it's just making calls to GTM, you have to configure that in GTM itself.
I believe the issue, particularly with iFrames (I have a similar use case) is that when setting cookies, GA will use the window's domain, not the iframe's so the cookies are considered Third Party, not First Party . Since Chrome uses "Lax" now instead of "None" as the default value for samesite, the cookies aren't able to be set/updated.
I actually had the same issue with this for UA, so it's a browser issue not the package I think.
@codal-matthew-fung that was a tough issue to solve, thank you for taking the time to share.
I have the exact same scenario as you, embeded react component in an iframe, using react-gtm and getting that error.