diff --git a/src/public/partials/consent.eta b/src/public/partials/consent.eta index 3230ae8..5873188 100644 --- a/src/public/partials/consent.eta +++ b/src/public/partials/consent.eta @@ -1,4 +1,3 @@ -
+ function setConsent(consent) { + const consentMode = { + 'functionality_storage': consent.necessary ? 'granted' : 'denied', + 'security_storage': consent.necessary ? 'granted' : 'denied', + 'ad_storage': consent.marketing ? 'granted' : 'denied', + 'analytics_storage': consent.analytics ? 'granted' : 'denied', + 'personalization_storage': consent.preferences ? 'granted' : 'denied', + }; + gtag('consent', 'update', consentMode); + localStorage.setItem('consentMode', JSON.stringify(consentMode)); + } + \ No newline at end of file diff --git a/tutorials/4-consent-mode/src/public/partials/consent.eta b/tutorials/4-consent-mode/src/public/partials/consent.eta index 3230ae8..5873188 100644 --- a/tutorials/4-consent-mode/src/public/partials/consent.eta +++ b/tutorials/4-consent-mode/src/public/partials/consent.eta @@ -1,4 +1,3 @@ - + function setConsent(consent) { + const consentMode = { + 'functionality_storage': consent.necessary ? 'granted' : 'denied', + 'security_storage': consent.necessary ? 'granted' : 'denied', + 'ad_storage': consent.marketing ? 'granted' : 'denied', + 'analytics_storage': consent.analytics ? 'granted' : 'denied', + 'personalization_storage': consent.preferences ? 'granted' : 'denied', + }; + gtag('consent', 'update', consentMode); + localStorage.setItem('consentMode', JSON.stringify(consentMode)); + } + \ No newline at end of file