Created
September 28, 2022 14:29
-
-
Save NickDeckerDevs/cacf60a76c5e98da75b615fce4bfe3c2 to your computer and use it in GitHub Desktop.
hubpsot gdpr api script
This file contains 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
var _hsp = window._hsp = window._hsp || [] | |
window.dataLayer = window.dataLayer || [] | |
_hsp.push(['addPrivacyConsentListener', function(consent) { | |
// console.log('-------- [HubSpot website logging start] --------') | |
// console.log('analytics: ' + consent.categories.analytics) | |
// console.log('advertisement: ' + consent.categories.advertisement) | |
// console.log('functionality: ' + consent.categories.functionality) | |
// console.log('-------- [HubSpot website logging start] --------') | |
if(consent.categories.analytics) { | |
window.dataLayer.push({ | |
'event': 'gdprAnalyticsAccept' | |
});a | |
} else { | |
window.dataLayer.push({ | |
'event': 'gdprAnalyticsDeny' | |
}); | |
} | |
if(consent.categories.advertisement) { | |
window.dataLayer.push({ | |
'event': 'gdprAdvertisementAccept' | |
}); | |
} else { | |
window.dataLayer.push({ | |
'event': 'gdprAdvertisementDeny' | |
}); | |
} | |
if(consent.categories.functionality) { | |
window.dataLayer.push({ | |
'event': 'gdprFunctionalityAccept' | |
}); | |
} else { | |
window.dataLayer.push({ | |
'event': 'gdprFunctionalityDeny' | |
}); | |
} | |
}]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment