Closed saschafoerster closed 2 years ago
Hi @saschafoerster, right now you'd have to do this via a callback, we'll add a way to clean up localStorage / sessionStorage keys with the next release though!
Is this already implemented but maybe not documented? There have been 9 releases since we'll add a way to clean up localStorage / sessionStorage keys with the next release though
and I found no information on this topic in the release notes.
Is there still anything about clearing the local storage, or has the idea died ? Where can i get documentation, how to use/configure the callbackfunction ?
Where can i get documentation, how to use/configure the callbackfunction ?
@69bruno: There is an example in the annotated config.js:
// An optional callback function that will be called each time
// the consent state for the service changes (true=consented). Passes
// the `service` config as the second parameter as well.
callback: function(consent, service) {
// This is an example callback function.
console.log(
'User consent for service ' + service.name + ': consent=' + consent
);
// To be used in conjunction with Matomo 'requireCookieConsent' Feature, Matomo 3.14.0 or newer
// For further Information see https://matomo.org/faq/new-to-piwik/how-can-i-still-track-a-visitor-without-cookies-even-if-they-decline-the-cookie-consent/
/*
if(consent==true){
_paq.push(['rememberCookieConsentGiven']);
} else {
_paq.push(['forgetCookieConsentGiven']);
}
*/
},
Update: A quick fix I used in my case was this to remove all elements beginning with "us-" from the local storage:
callback: function (consent, service) {
if (consent == false) {
Object.keys(localStorage).filter(x => x.startsWith('us-')).forEach(x => localStorage.removeItem(x))
}
},
Source: https://stackoverflow.com/questions/24551578/clear-localstorage-values-with-certain-prefix
Thank you, that worked and helped clean the local storage!
I am trying to use Klaro with Mautic: https://www.mautic.org
Mautic is using cookies and local storage as well. When I consent one time to use Mautic, then cookies as well as local storage are used. When I remove my consent later in the cookie-modal, then only the cookies will be deleted.
This is the relevant part of my configuration:
Did I misconfigure something? Or is Klaro not able to cleanup local storage? I added
to try out, if local storage is deleted, when I don't define any domain, but now I don't have any more ideas.