Skip to content

Commit

Permalink
Fix error when declining analytics cookies
Browse files Browse the repository at this point in the history
  • Loading branch information
matteason committed Nov 21, 2023
1 parent b8eb65c commit 6764a0e
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions src/main/resources/public/assets/scripts/cookieControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,21 @@
denyConsentScripts: [
// Google Analytics
function() {
function gtag(){dataLayer.push(arguments);}
// dataLayer will only exist on window if they've already consented to analytics. If that's the case, we update
// consent preferences in the Google tag to ensure cookies aren't recreated
if(window.hasOwnProperty("dataLayer")) {
function gtag() {
dataLayer.push(arguments);
}

gtag("consent", "default", {
ad_storage: "denied",
analytics_storage: "denied",
functionality_storage: "denied",
personalization_storage: "denied",
security_storage: "denied"
});
gtag("consent", "default", {
ad_storage: "denied",
analytics_storage: "denied",
functionality_storage: "denied",
personalization_storage: "denied",
security_storage: "denied"
});
}
}
],
setCookie: function (name,value,days) {
Expand Down

0 comments on commit 6764a0e

Please sign in to comment.