Skip to content
All documentation pages

Reference

Consent mode

The tracker stores nothing on the visitor’s device. If your policy is still to wait for consent, it can hold everything until your banner says yes.

Wait for consent before recording

Script tagHTML
<script defer
  src="https://cdn-stg.webmetric.io/v1/b.js"
  data-key="wm_w_your_write_key"
  data-host="https://in-stg.webmetric.io"
  data-consent="required"></script>

With data-consent="required", nothing is recorded or sent until your consent banner calls:

When the visitor agreesJavaScript
window.webmetric.consent(true);

The choice is not stored, because the tracker writes nothing to the device. Call consent(true) on every page load once your banner knows the answer.

If the visitor withdraws, call consent(false). Recording stops and anything not yet sent is discarded.

When the visitor withdrawsJavaScript
window.webmetric.consent(false);

Wait for consent before replay only

With data-replay="consent", analytics runs as normal and the session recorder loads only after consent(true). consent(false) stops a recording in progress.

When your banner answers first

Your banner may answer before the tracker has loaded. Add this stub before the script tag and call window.webmetric.consent(true) as usual. The answer is applied when the tracker starts.

Before the script tagHTML
<script>
  window.webmetric = window.webmetric || {
    q: [],
    track: function () { this.q.push(arguments); },
    consent: function (granted) { this.c = granted; },
  };
</script>

With the npm package

npmTypeScript
import { consent, init } from "@webmetric/sdk";

init({
  key: "wm_w_your_write_key",
  host: "https://in-stg.webmetric.io",
  consent: "required",
});

consent(true);

Browser signals always win

A visitor whose browser sends Do Not Track or Global Privacy Control is never recorded, even after consent(true).

Do you need a banner?

That depends on where you and your visitors are, and on what else your site runs. Ask your legal adviser. The privacy page describes exactly what the tracker collects, which is what they will want to know.