You can under some circumstances track your visitors using Matomo without needing cookie or tracking consent. If this applies to you, it means you can track any visitor even if 1) you don’t have any consent yet, and 2) even if the user declines or rejects cookie consent.

You need to add the following line to your tracking code:

_paq.push(['requireCookieConsent']);

Once you added the line above, then all visitors will be tracked with tracking cookies disabled.

If you want to ask for consent

If you then also want to ask visitors for cookie consent (optional), simply follow these instructions on how to implement cookie consent in your website or app. In a nutshell, as soon as consent for using cookies is given, simply call: _paq.push(['rememberCookieConsentGiven']); once, or call: _paq.push(['setCookieConsentGiven']); on every subsequent page view. (Then all visitors will be tracked, and tracking cookies will be set.)

And once the cookie consent has been revoked, simply call: _paq.push(['forgetCookieConsentGiven']); once, or no longer call _paq.push(['setCookieConsentGiven']); on every subsequent page view. (Then all visitors will be tracked, but tracking cookies will be disabled.)

Please note this requires Matomo 3.14.0.