Hi,
I am trying to setup Matomo for my webapp in a way that
(i) users can give and revoke consent whenever they want,
(ii) Matomo tracks user action during times when consent is given,
(iii) Matomo does not track anything at all during times when no consent is given.
My setup currently looks like this:
<script type="text/javascript">
var _paq = window._paq = window._paq || [];
_paq.push(['requireConsent']);
_paq.push(['trackPageView']);
// Load Matomo, but don't track anything yet
(function() {
var u="my_url";
_paq.push(['setTrackerUrl', u+'.php']);
_paq.push(['setSiteId', 1234]);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.type='text/javascript'; g.async=true; g.src=u+'.js'; s.parentNode.insertBefore(g,s);
})();
</script>
Depending on user choice I set the following parameters:
// start tracking
if (n_clicks_all || switch_performance) {
_paq.push(['setConsentGiven']);
_paq.push(['enableLinkTracking']);
_paq.push(['trackPageView']);
} else {
// stop tracking
_paq.push(['forgetConsentGiven']);
}
This works up to a point. When a user gives consent, revokes it later and gives it again after that, all the actions he did during the time without consent are sent to the Matomo server together. I want any action undertaken by user during a time without consent to be forgotten or better, not tracked in the first place. Is this possible? Maybe the term “consent” in a Matomo meaning is not exactly what I am looking for, but I guess one can understand what I am aiming for.
Thank you very much