How do I track a visitor without cookies when they have not given consent for tracking cookies?
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.
Segmenting people by consent
Visitors that have cookies disabled will impact the data accuracy of some reports. That’s why we have a feature that lets you segment these two different groups (visitors that were using cookies vs visitors that weren’t using cookies). It allows you to create a segment “Visitor gave consent” and view the reports that impact the data accuracy only for these users that gave consent. When you apply this segment “Visitor gave consent” you will get reliable numbers, compared to looking at “All visits” where people without consent would make these reports inaccurate.