Skip to content

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.

  1. Add data-consent="required" to the generated script.

    <script defer data-consent="required" src="https://analytics.example.com/js/YOUR_SITE_ID.js"></script>
  2. Resolve the gate after the visitor chooses.

    window.supermetry.consent(true); // grant and send queued events
    window.supermetry.consent(false); // deny, clear the queue, and stop sends
  3. In Settings → Tracking, keep Respect browser privacy signals enabled. This drops requests carrying Global Privacy Control or Do Not Track.

  4. Offer a visitor-level opt-out if your privacy controls require one.

    window.supermetry.optOut(); // stores supermetry_ignore and stops collection
    window.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.