Skip to content

Commit

Permalink
updated disable ga cookies
Browse files Browse the repository at this point in the history
  • Loading branch information
nikiwycherley committed Jun 21, 2023
1 parent 66d6f4e commit eb0b2dc
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions server/src/js/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,19 +95,16 @@ window.flood = {
},
disableGoogleAnalytics: () => {
const script = document.createElement('script')
script.text = `window['ga-disable-${process.env.GA4_ID}'] = true;`
script.text = `
if (!window.flood.utils.getCookie('set_cookie_usage')) {
window['ga-disable-${process.env.GA4_ID}'] = true;
} else {
window['ga-disable-${process.env.GA4_ID}'] = false;
}
`
document.head.appendChild(script)

const gtagScript = document.createElement('script')
gtagScript.async = true
gtagScript.src = `https://www.googletagmanager.com/gtag/js?id=${process.env.GA4_ID}`
gtagScript.onload = () => {
window.dataLayer = window.dataLayer || []
function gtag () { window.dataLayer.push(arguments) }
gtag('js', new Date())
gtag('config', process.env.GA4_ID)
}
document.head.appendChild(gtagScript)
// Rest of the function...
}
}
}
Expand Down

0 comments on commit eb0b2dc

Please sign in to comment.