diff --git a/Configuration/Settings.yaml b/Configuration/Settings.yaml index fc37d3c..701cedb 100644 --- a/Configuration/Settings.yaml +++ b/Configuration/Settings.yaml @@ -28,6 +28,7 @@ KaufmannDigital: consentLogEnabled: false consentDimensions: [] cookieName: 'KD_GDPR_CC' + cookieDomainName: null # See README.md # - language # - country diff --git a/Resources/Private/Fusion/Root.fusion b/Resources/Private/Fusion/Root.fusion index f562c39..fa413e6 100644 --- a/Resources/Private/Fusion/Root.fusion +++ b/Resources/Private/Fusion/Root.fusion @@ -18,6 +18,7 @@ prototype(Neos.Neos:Page) { value = ${Array.join(this.dimensionValues, '_')} } @context.cookieName = ${Configuration.setting('KaufmannDigital.GDPR.CookieConsent.cookieName')} + @context.cookieDomainName = ${Configuration.setting('KaufmannDigital.GDPR.CookieConsent.cookieDomainName')} @@ -27,6 +28,7 @@ prototype(Neos.Neos:Page) { var KD_GDPR_CC = { apiUrl: '" + apiUrl + "', cookieName: '" + cookieName +"', + cookieDomainName: '" + cookieDomainName +"', versionTimestamp: " + versionDate.timestamp * 1000 + ", dimensionsIdentifier: '" + (dimensionsIdentifier != '' ? dimensionsIdentifier : 'default') + "' }; diff --git a/Resources/Public/JavaScript/Main.js b/Resources/Public/JavaScript/Main.js index 0383b70..d960d83 100644 --- a/Resources/Public/JavaScript/Main.js +++ b/Resources/Public/JavaScript/Main.js @@ -212,7 +212,8 @@ function saveConsentToCookie(inputs, userId) { expireDate: expireDate.toUTCString() }; - document.cookie = KD_GDPR_CC.cookieName + "=" + encodeURI(JSON.stringify(cookieData)) + "; expires=" + expireDate.toUTCString() + "; path=/; Secure;"; + var cookieParams = encodeURI(JSON.stringify(cookieData)) + "; expires=" + expireDate.toUTCString() + "; path=/; " + (KD_GDPR_CC.cookieDomainName ? ('domain=' + KD_GDPR_CC.cookieDomainName + ';') : '') +" Secure;"; + document.cookie = KD_GDPR_CC.cookieName + "=" + cookieParams; window.dataLayer = window.dataLayer || []; window.dataLayer.push({