Open ahegyes opened 1 year ago
Hi @joshfleming!
I tested my original PR submission from yesterday on our fork of this plugin for https://dayoneapp.com/. But I wasn't very happy with that solution since it prevented trackers from running on the first page load even for US visitors since we just blocked everything as long as there was no geo data stored in the cookies.
Today I've extended my solution in two ways:
The gtag( 'consent', 'update', {...} )
call now no longer happens for defaults preferences; this lets GTM/Google decide which tags to fire based on their own geolocalization; this lets us fire trackers in the US on first visit while they stay blocked in the EU;
In the function setTrackingPrefs
there is a call to gtag( 'consent', 'update', {...} )
but it would only execute if the function gtag
was defined by some other script; during the build process, the one defined in gtm-init.ts
would be renamed but I made it now such that they are one-and-the-same.
I've tested this exact PR locally, and these changes are also live on our fork at https://dayoneapp.com/. This is just a suggestion of how the problem can be addressed, feel free to ignore it if you have a different/better idea 😄
When the cookies for geolocation are not set yet, default to a
disallowAll
approach instead of anallowAll
one.See #19