Consent
What is consent?
In many regions (EU GDPR, ePrivacy) — you must get user consent before starting analytics.
Matomo supports this via requireConsent mode.
When this is active:
✅ No tracking is sent until the user gives consent.
How to enable consent in Matomo
You must configure Matomo to require consent.
In Matomo UI:
- Go to Administration → Privacy → Tracking Code.
- Enable: Require user consent.
This adds:
_paq.push(["requireConsent"]);
Grant consent
When the user accepts:
(window as any)._paq?.push(["rememberConsentGiven"]);
Revoke consent
If the user later opts out:
(window as any)._paq?.push(["forgetConsentGiven"]);
Example React UI
const ConsentBanner = () => {
const accept = () => {
(window as any)._paq?.push(["rememberConsentGiven"]);
};
const decline = () => {
(window as any)._paq?.push(["forgetConsentGiven"]);
};
return (
<div>
<p>We use analytics to improve the app. OK?</p>
<button onClick={accept}>Accept</button>
<button onClick={decline}>Decline</button>
</div>
);
};
Important
The library does not force you to use consent.
You must:
✅ Enable it in Matomo if needed
✅ Implement your own UI
✅ Call the APIs shown above