Skip to content

Commit

Permalink
Task: Configurable cookie domain
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikdro committed Feb 25, 2021
1 parent 19ad6dd commit 9ef017c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions Configuration/Settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ KaufmannDigital:
consentLogEnabled: false
consentDimensions: []
cookieName: 'KD_GDPR_CC'
cookieDomainName: null
# See README.md
# - language
# - country
Expand Down
2 changes: 2 additions & 0 deletions Resources/Private/Fusion/Root.fusion
Original file line number Diff line number Diff line change
Expand Up @@ -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')}



Expand All @@ -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') + "'
};
Expand Down
3 changes: 2 additions & 1 deletion Resources/Public/JavaScript/Main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down

0 comments on commit 9ef017c

Please sign in to comment.