klaro-js icon indicating copy to clipboard operation
klaro-js copied to clipboard

klaro + Matomo's requireCookieConsent Feature

Open futureweb opened this issue 2 years ago • 4 comments

Hey there,

I've got a Question and I hope someone here can give me a helping hand on that! ;-)

I'm using klaro this way:

  • within klaro - Matomo Consent is deactivated by default
  • within Matomo I'm using the requireCookieConsent - so it won't use cookies without consent given
  • When consent is given within klaro - the rememberCookieConsentGiven Function of Matomo is triggered which itself turns on some more features/cookies ...

The Problem: Matomo is deactivated within klaro - but the matomo script should be normally executed and only the rememberCookieConsentGiven should be triggered when consent is given.

To execute the Script even Matomo is deactivated within klaro i'm using type="application/javascript" instead of type="text/plain" ... but since one of the latest klaro updates it seems klaro is reverting the type to type="text/plain" itself on load. And when consent is given ... the

grafik

{
  name: 'matomo',
  default: false,
  required: false,
  optOut: false,
  title : 'Matomo',
  purposes: ['analytics'],
  cookies: [
    [/^_pk_.*$/i, '/'],
    [/^piwik_ignore/, '/', 'stats.futureweb.at'],
    [/^piwik_ignore/, '/']
  ],
  callback: function(consent, app) {
    if (consent == true) {
	    _paq.push(['rememberCookieConsentGiven']);
    } else {
	    _paq.push(['forgetCookieConsentGiven']);
    }
  }
}
<script type="application/javascript" data-type="application/javascript" data-name="matomo">
  Matomo Script Things ...
</script>

How can I achieve the old behaviour?

  • Matomo deactivated within klaro but Matomo script executed
  • klaro only toggling a JS Function when consernt is given / taken?

grafik

Reproduce:

  1. go to https://www.futureweb.at/
  2. accept all Cookies
  3. reload Page and have a look into Console

Thank you, bye from sunny Austria Andreas

btw) initially we had it solved it this way within this Issue: https://github.com/kiprotect/klaro/issues/223

futureweb avatar Mar 08 '22 09:03 futureweb