Require tracking consent
Hold browser events until consent and support privacy signals and visitor opt-out.
Gate collection on your consent choice while keeping browser privacy controls available.
-
Add
data-consent="required"to the generated script.<script defer data-consent="required" src="https://analytics.example.com/js/YOUR_SITE_ID.js"></script> -
Resolve the gate after the visitor chooses.
window.supermetry.consent(true); // grant and send queued eventswindow.supermetry.consent(false); // deny, clear the queue, and stop sends -
In Settings → Tracking, keep Respect browser privacy signals enabled. This drops requests carrying Global Privacy Control or Do Not Track.
-
Offer a visitor-level opt-out if your privacy controls require one.
window.supermetry.optOut(); // stores supermetry_ignore and stops collectionwindow.supermetry.optIn(); // removes the flag and resumes collection
The opt-out flag is the tracker’s only local-storage key. GPC and DNT still veto browser collection after optIn() or consent is granted.
What you should see: no events are sent before consent; granting consent sends queued events unless a privacy signal or opt-out blocks them.