Skip to content

Commit

Permalink
PLANET-7409: Implement new parameters on Google Consent Mode (#2215)
Browse files Browse the repository at this point in the history
  • Loading branch information
lithrel committed Mar 5, 2024
1 parent 6f3ce59 commit c0c5e6b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions assets/src/js/cookies.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ export const setupCookies = () => {
if (ENABLE_GOOGLE_CONSENT_MODE) {
updateGoogleConsent({
ad_storage: 'granted',
ad_user_data: 'granted',
ad_personalization: 'granted',
...ENABLE_ANALYTICAL_COOKIES && {analytics_storage: 'granted'},
});
}
Expand Down Expand Up @@ -155,6 +157,8 @@ export const setupCookies = () => {
if (ENABLE_GOOGLE_CONSENT_MODE) {
updateGoogleConsent({
ad_storage: marketingCookiesChecked ? 'granted' : 'denied',
ad_user_data: marketingCookiesChecked ? 'granted' : 'denied',
ad_personalization: marketingCookiesChecked ? 'granted' : 'denied',
...ENABLE_ANALYTICAL_COOKIES && {analytics_storage: analyticalCookiesChecked ? 'granted' : 'denied'},
});
}
Expand All @@ -176,6 +180,8 @@ export const setupCookies = () => {
if (ENABLE_GOOGLE_CONSENT_MODE) {
updateGoogleConsent({
ad_storage: 'denied',
ad_user_data: 'denied',
ad_personalization: 'denied',
...ENABLE_ANALYTICAL_COOKIES && {analytics_storage: 'denied'},
});
}
Expand Down
6 changes: 6 additions & 0 deletions templates/blocks/google_tag_manager.twig
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
if ( cookie_consent ) {
var capabilities = {
ad_storage: marketing_consent ? 'granted' : 'denied',
ad_user_data: marketing_consent ? 'granted' : 'denied',
ad_personalization: marketing_consent ? 'granted' : 'denied',
{% if cookies.enable_analytical_cookies %}
...{'analytics_storage': analytical_consent ? 'granted' : 'denied'}
{% endif %}
Expand All @@ -35,11 +37,15 @@
} else {
var capabilities = {
ad_storage: 'denied',
ad_user_data: 'denied',
ad_personalization: 'denied',
{% if cookies.enable_analytical_cookies %}
...{'analytics_storage': 'denied'}
{% endif %}
};
gtag('consent', 'default', capabilities);
gtag('set', 'url_passthrough', true);
gtag('set', 'ads_data_redaction', capabilities.ad_storage === 'denied');
dataLayer.push({event: 'defaultConsent', ...capabilities});
}
{% endif %}
Expand Down

0 comments on commit c0c5e6b

Please sign in to comment.