I've previously implemented a custom consent form which I use on my Matomo-enabled websites.
If a user opts-in to tracking, it calls
_paq.push(['rememberConsentGiven']);. If a user opts-out, it calls
_paq.push(['forgetConsentGiven']);. Matomo then set the
mtm_consent_removed cookies respectively. If either of those cookies were set, I knew the user had made a consent decision, so the opt-in message wasn't shown to the user again.
At some point recently, it seems the behaviour of
_paq.push(['forgetConsentGiven']); has changed.
mtm_consent_removedcookie and unsets the
mtm_consentis not set,
_paq.push(['forgetConsentGiven']);has no effect.
_paq.push(['forgetConsentGiven']);unsets it and sets
Is this an intentional Matomo API change? I can't find it in any changelogs or documentation.
The method should
It should do this no matter if
mtm_consent is set or not set see https://github.com/matomo-org/matomo/blob/3.14.0/js/piwik.js#L7815-L7818
If mtm_consent is not set, _paq.push(['forgetConsentGiven']); has no effect.
It is possible that in this case the cookies are disabled and therefore the call to set the
mtm_consent_removed cookie doesn't work. If that's the case, we fixed this already in Matomo 4 (which will be released in 1-2 weeks) and also backported this yesterday to our 3.X branch so it will be included in the next release (not sure when the next 3.X release will be) https://github.com/matomo-org/matomo/pull/16668/files
Hey @tsteur, thank you for your response. I've just been testing it on my browser, calling the two methods in the console, and that's the behaviour I've noticed. Cookies are enabled, as far as I know -- I've got
requireConsent in my initial Matomo script, but I've not called
disableCookies. Is there another way they can be disabled?
requireConsent can disable cookies directly. So that's likely what's happening and the next release should fix this already.
Ah, I see. I've just updated to Matomo 4.0.0-rc2, and can confirm that this issue is fixed.
Thank you for your help!