From e8fa80c07319b801531111d61a6720397b136a3d Mon Sep 17 00:00:00 2001 From: Matt Landers Date: Mon, 13 May 2024 13:34:15 -0500 Subject: [PATCH] fix for personalization settings --- src/public/partials/consent.eta | 105 +++++++++--------- .../src/public/partials/consent.eta | 105 +++++++++--------- 2 files changed, 102 insertions(+), 108 deletions(-) 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