Last active
September 22, 2023 21:53
-
-
Save elephantsneverforget/6ed2b4052a07c560d04fe3efb096a6a6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.dataLayer = window.dataLayer || []; | |
function gtag(){dataLayer.push(arguments);} | |
function getCookie(name) { | |
let value = "; " + document.cookie; | |
let parts = value.split("; " + name + "="); | |
if (parts.length == 2) return parts.pop().split(";").shift(); | |
} | |
let consent = getCookie("__zulily_consent_granted"); // or localStorage.getItem("__zulily_consent_granted") | |
// Push appropriate consent states | |
if (consent === "true" || !consent) { | |
// Push all consent states as accepted | |
gtag('consent', 'update', { | |
'ad_storage': 'granted', | |
'analytics_storage': 'granted', | |
'functionality_storage': 'granted', | |
'personalization_storage': 'granted', | |
'security_storage': 'granted' | |
}); | |
} else { | |
// Push all consent states as revoked | |
gtag('consent', 'update', { | |
'ad_storage': 'denied', | |
'analytics_storage': 'denied', | |
'functionality_storage': 'denied', | |
'personalization_storage': 'denied', | |
'security_storage': 'granted' //always granted | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment