-
-
Notifications
You must be signed in to change notification settings - Fork 424
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
[Feat]: Google Consent Mode v2 #665
Comments
See #523. |
Thank you for your response. Here is an example of how it can be handled: Would this be possible to implement? |
I think so yes - here's how I did it, partly based on this comment: Tag-Manager in <script>
// Define dataLayer and the gtag function.
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
// Set default consent to 'denied' as a placeholder
// Determine actual values based on your own requirements
gtag('consent', 'default', {
'ad_storage': 'denied',
'ad_user_data': 'denied',
'ad_personalization': 'denied',
'analytics_storage': 'denied'
'functionality_storage': 'denied',
'personalization_storage': 'denied',
});
</script>
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=TAG_ID">
</script>
<script>
gtag('js', new Date());
gtag('config', 'TAG_ID');
</script> Update-function in CookieConsent - callbacks: CookieConsent.run({
// ...
onConsent: () => {
updateGtagConsent();
},
onChange: ({ changedCategories }) => {
updateGtagConsent();
},
});
function updateGtagConsent() {
gtag('consent', 'update', {
'ad_storage': CookieConsent.acceptedCategory('advertisement') ? 'granted' : 'denied',
'ad_user_data': CookieConsent.acceptedCategory('advertisement') ? 'granted' : 'denied',
'ad_personalization': CookieConsent.acceptedCategory('advertisement') ? 'granted' : 'denied',
'analytics_storage': CookieConsent.acceptedCategory('analytics') ? 'granted' : 'denied',
'functionality_storage': CookieConsent.acceptedCategory('functional') ? 'granted' : 'denied',
'personalization_storage': CookieConsent.acceptedCategory('functional') ? 'granted' : 'denied',
});
} Edit: <script async src="https://www.googletagmanager.com/gtag/js?id=TAG_ID" type="text/plain" data-category="analytics">
</script> |
Hey @FynnZW the script I use to load Tag Manger looks very different yours. Have you had your implementation in for a long while? This is the code that google suggests I use: <script type="text/plain" data-cookiecategory="performance">
(function (w, d, s, l, i) {
w[l] = w[l] || [];
w[l].push({
'gtm.start':
new Date().getTime(), event: 'gtm.js'
});
var f = d.getElementsByTagName(s)[0],
j = d.createElement(s), dl = l != 'dataLayer' ? '&l=' + l : '';
j.async = true;
j.src =
'https://www.googletagmanager.com/gtm.js?id=' + i + dl;
f.parentNode.insertBefore(j, f);
})(window, document, 'script', 'dataLayer', 'TAG_ID');
</script> |
Ignore that @FynnZW I hadn't worked out it was just a case of putting the |
Going back to the main point of this issue: I don't plan on having any default embedded service in the plugin. I can, however, add a dedicated section in the docs. on how to set up google consent mode v2. |
@FynnZW Hi, when using the Tag Inspector with your solution, I see some problems. In Tag Inspector, if the user grant consent by clicking Which means for exemple that my Facebook Pixel is blocked, because the consent is still the default How would I make sure the consent from orestbida/cookieconsent (vanilla-cookieconsent) is read from the cookie before my containers are loaded ? |
Something like this article would be very helpful. The article uses v2.9, an update for 3 would be great. |
Looking forward to implement the cookie consent in version 3. |
Hello everyone, I think this article is still very useful. |
Do I need to do anything inside Google Tagmanager also, or is the code above sufficient? It seems pretty straightforward. |
I would also like to know if we have to do anything else to handle for example Google Analytics and Google Ads in GTM |
You still need to configure in GTM, which consent categories are associated with which tags. |
Thanks. From what I understand: in our scenario we're only using Google Analytics, and the analytics_storage tag. According to the video "google tags are already aware of consent mode and are already working". Google Tag Manager is only needed for additional settings. The Consent Settings that is mentioned in the video is not available for me. I've used the preview in Google Tag Manager and it seems the analytics_storage tag is connected to Cookie Consent. |
Description
Due to Google's recent requirement to switch to Cookie Consent Mode V2, many users are requesting to switch to platforms certified by Google itself such as Iubenda, CookieBot, etc.
Is it possible to implement this functionality and be accredited as a Google certified platform?
Thank you for your attention
Proposed solution
Set up consent mode:
https://developers.google.com/tag-platform/security/guides/consent?consentmode=advanced#upgrade-consent-v2
I also found this certification form:
https://support.google.com/admanager/contact/cmp_certification_interest?hl=en&sjid=780032960389095808-EU
Additional details
No response
The text was updated successfully, but these errors were encountered: