New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Google Consent Mode #342
Comments
+1 |
Hey @afanjul and @jmalinens, we already support Google Consent Mode (GCM) and advanced consent modes for Google Tag Manager (GTM), currently this is only available in our hosted solution as it's enabled via the Klaro service catalog. To be honest I'm still a bit hesitant on whether we should integrate the service catalog (which is currently still open-source) into the OS version, as it takes a lot of effort writing and maintaining it, so we might have to keep that in the paid version only. However, we have a tutorial that shows how to integrate Klaro with GCM and GTM, which also works for the open-source vesion: https://kiprotect.com/docs/klaro/tutorials/google_tag_manager It requires Klaro |
Thanks @adewes, I did review the code for google_tag_manager, but regarding the Google Consent Mode I think that there is something wrong, or maybe something that I missing, because the Google Consent Mode allows you to precisely always load the google gtag/gtm script code BUT at the same time allows you to configure the consent mode (as long as you set your consent mode before the gtm script code) to avoid use cookies. The problem with Klaro is that as soon as you declined the Google Service, the gtag/gtm code won't be loaded so you won't use the new Google mode consent (in deed you won't load any google gtag/gtm base code at all). Do I missing something? BTW: I think there is a typo using opts.vars.googleAnalyticsName var name instead of opts.vars.googleAnalytics. |
Hi @afanjul, thanks for the reply! So there are several ways to go about this:
Personally I'd prefer to disable all tracking if the user declines consent but I know that the consent mode is specifically designed to be used in such a case (though I don't fully agree with Googles' reasoning), so it's up to you as a publisher on how you want to use this. So, in a nutshell: If you want to always load GTM, simply change the purposes to |
There is a third option that I'm trying to figure out now (and testing it for Google Analytics & Ads global gtag, not GTM by now) that is not to modify the original script (ie. let the type attribute as javascript, etc.) and just add the service with the callback functions. So the base code would be like this:
And the GoogleAnalytics (and Ads) services would be like this:
You don't need the onInit callback because the init code it is already added before the base script loading, and moreover it won't ever work because onAccept (thrown through a deferred script) always will be thrown AFTER the async google gtag code in head. |
Great idea, I didn't think of that! If you configure GTM correctly this is an option as well, just make sure it won't load additional scripts until the user grants consent. That said I think it's always best to not load any third-party scripts before the user has given consent. |
@afanjul I am trying to implement google consent v2, could you please share the solutions you ended up with? |
With the release of Google Consent Mode, we could still be tracking users (for Google Ads, Google Analytics, etc.) even without cookies (so complying with the law). Google has launched this mode with the API here: https://developers.google.com/gtagjs/devguide/consent
You could consider to add this mode to the Klaro library.
The text was updated successfully, but these errors were encountered: