Integrating with Cookie Information
To set up Cookieless Account Analytics with Cookie Information you will need to add some custom code for Cookieless to fire correctly.
In the Javascript V2 source in Dreamdata you will find your scripts (go through the setup if they have not been generated yet). The script consists of two tags; the first one is regular analytics and the second one is Cookieless Account Analytics.
You now need to modify the Cookieless Account Analytics tag to run only when the consent has not been given for regular analytics. This can be accomplished by something like this:
<script>
function isStatisticConsentGiven() {
function getCookie(cookieName) {
var cookies = document.cookie.split('; ')
for (let cookie of cookies) {
var [name, value] = cookie.split('=')
if (name === cookieName) {
return value
}
}
return null
}
var cookieValue = getCookie('CookieInformationConsent')
if (cookieValue) {
try {
var decodedPayload = decodeURIComponent(cookieValue)
var consentData = JSON.parse(decodedPayload)
var consentsApproved = consentData.consents_approved || []
// Insert your consent here
return consentsApproved.includes('cookie_cat_statistic')
} catch (error) {
return false
}
} else {
return false
}
}
!(function () {
if (
!window.dreamdata ||
!window.dreamdata.initialized ||
!isStatisticConsentGiven()
) {
// The rest of the code
}
})()
</script>