diff --git a/Configuration/Settings.yaml b/Configuration/Settings.yaml index 96d4a71..937aee2 100644 --- a/Configuration/Settings.yaml +++ b/Configuration/Settings.yaml @@ -25,6 +25,7 @@ KaufmannDigital: CookieConsent: siteCSSFilepath: null customCSSFilepath: null + consentLogEnabled: false siteStyles: [] # "rootNode name 1": # siteCSSFilepath: diff --git a/README.md b/README.md index efb0098..3a1e413 100644 --- a/README.md +++ b/README.md @@ -104,6 +104,14 @@ KaufmannDigital: ``` *Hint: We are working on advanced styling options. Different style- and positioning presets will be available in future. If you have any wishes or created a cool design for this banner yourself, please contact us.* +### Consent Logging +The package provides the ability to track the users decisions by storing the chosen consent identifiers along with a random user id and the user agent in your database. This feature is disabled by default, you can enable it in your Settings.yaml: +```yaml +KaufmannDigital: + GDPR: + CookieConsent: + consentLogEnabled: true +``` ## Roadmap / Planned Features diff --git a/Resources/Private/Fusion/Renderers/Renderer.CookieSettings.fusion b/Resources/Private/Fusion/Renderers/Renderer.CookieSettings.fusion index dab96a5..706b774 100644 --- a/Resources/Private/Fusion/Renderers/Renderer.CookieSettings.fusion +++ b/Resources/Private/Fusion/Renderers/Renderer.CookieSettings.fusion @@ -120,6 +120,8 @@ prototype(KaufmannDigital.GDPR.CookieConsent:Content.CookieSettings.Renderer) < jsVariables = Neos.Fusion:Tag { tagName = 'script' + consentLogEnabled = ${Configuration.Setting('KaufmannDigital.GDPR.CookieConsent.consentLogEnabled') ? 'true' : 'false'} + trackChoiceUrl = Neos.Fusion:UriBuilder { package = 'KaufmannDigital.GDPR.CookieConsent' controller = 'Api' @@ -136,6 +138,7 @@ prototype(KaufmannDigital.GDPR.CookieConsent:Content.CookieSettings.Renderer) < content = ${' var trackChoiceUrl = "' + this.trackChoiceUrl + '"; var generatedJsUrl = "' + this.generatedJsUrl + '"; + var consentLogEnabled = ' + this.consentLogEnabled + '; '} } diff --git a/Resources/Public/JavaScript/Main.js b/Resources/Public/JavaScript/Main.js index 94b03da..fcadd67 100644 --- a/Resources/Public/JavaScript/Main.js +++ b/Resources/Public/JavaScript/Main.js @@ -38,16 +38,17 @@ function initializeCookieConsent() { var btnAcceptNecessaryCookies = document.querySelector('#gdpr-cc-btn-accept-necessary'); //Create log in BE and store userID - var xhr = new XMLHttpRequest(); - xhr.open('POST', trackChoiceUrl); - xhr.setRequestHeader("Content-Type", "application/json;charset=UTF-8"); - xhr.onreadystatechange = function() { - if(xhr.readyState === 4) { - kd_gdpr_cc_userid = JSON.parse(xhr.response).userId; - } - }; - xhr.send(); - + if (consentLogEnabled) { + var xhr = new XMLHttpRequest(); + xhr.open('POST', trackChoiceUrl); + xhr.setRequestHeader("Content-Type", "application/json;charset=UTF-8"); + xhr.onreadystatechange = function() { + if(xhr.readyState === 4) { + kd_gdpr_cc_userid = JSON.parse(xhr.response).userId; + } + }; + xhr.send(); + } btnIndividualSettingsEnable.addEventListener('click', function() { individualSettingsContainer.style.display = 'block'; @@ -222,10 +223,12 @@ function saveConsentToCookie(inputs, userId) { } }); - var xhr = new XMLHttpRequest(); - xhr.open('POST', trackChoiceUrl, false); - xhr.setRequestHeader("Content-Type", "application/json;charset=UTF-8"); - xhr.send(JSON.stringify({'choice': cookieData})); + if (consentLogEnabled) { + var xhr = new XMLHttpRequest(); + xhr.open('POST', trackChoiceUrl, false); + xhr.setRequestHeader("Content-Type", "application/json;charset=UTF-8"); + xhr.send(JSON.stringify({'choice': cookieData})); + } }