Skip to content

Commit

Permalink
Merge pull request #33 from feinheit/GAConsentManagement
Browse files Browse the repository at this point in the history
push actual user consent to GA
  • Loading branch information
yoshson authored Apr 23, 2024
2 parents b4cfe6b + bb54964 commit 4f398f6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion feincms3_cookiecontrol/static/f3cc.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ const onAccept = (accept) => (e) => {
renderModify()
renderAcceptedEmbeds()
injectAcceptedScripts()
updateGAConsentData()
}

const injectAcceptedScripts = () => {
Expand All @@ -160,6 +161,21 @@ const injectAcceptedScripts = () => {
}
}

const updateGAConsentData = () => {
const dataLayer = (window.dataLayer = window.dataLayer || [])
const status = getConsentToAll() ? "granted" : "denied"
dataLayer.push([
"consent",
"update",
{
ad_user_data: status,
ad_personalization: status,
ad_storage: status,
analytics_storage: status,
},
])
}

const mainElement = () => {
if (!mainElementRef) {
mainElementRef = crel("div", { [sClassName]: "f3cc" })
Expand Down

0 comments on commit 4f398f6

Please sign in to comment.