Skip to main content

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.


You must configure Matomo to require consent.

In Matomo UI:

  1. Go to Administration → Privacy → Tracking Code.
  2. Enable: Require user consent.

This adds:

_paq.push(["requireConsent"]);

When the user accepts:

(window as any)._paq?.push(["rememberConsentGiven"]);

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