Consent for replays and heatmaps
Replays and heatmaps come with a script of their own, the recorder. By default it waits for your consent banner: nothing is recorded or counted until the visitor agrees. This article shows how to connect your banner to it, for whoever sets up the site’s scripts and consent tool.
When you need consent
Replays record individual visits, and heatmaps read clicks and scrolling in visitors’ browsers. In the EU and UK, assume this needs the visitor’s consent; that’s why both wait by default. In the UK, heatmaps may instead fall under the statistics exception, with a clear notice and an easy opt-out (below).
The tracking script has no waiting mode of its own: it counts from the first page view. Whether that needs consent depends on the country; in Sweden and Germany, assume it does. Where it does, load the tracking script only after the visitor agrees. Using Lyli doesn’t by itself make your site compliant. Consent by place has how we read the rules today; it’s general information, not legal advice.
Connect your consent banner
Everything is in the site’s Settings › Recording, which only admins can change.
Turn on Replays, Heatmaps, or both under Replays and heatmaps. Both are off until an admin turns them on. Replays also need the site’s Individual visits on, since each replay is one visit; heatmaps only count, so they work either way.
Add the recorder to every page, next to the tracking script. Under Add the recorder, keep Wait for consent and copy the tag.
Have your consent banner run one line when a visitor agrees. It works before or after the recorder loads: the flag tells a recorder that hasn’t loaded yet, and the call starts one that has.
<script defer src="https://app.lyli.io/r.js" data-site="s_k3m9x2p7qa"
data-consent="wait"></script>window.lyliConsent = true; window.lyli?.record?.();- Run it on every page load for a visitor who has agreed, not only when they first click. The recorder doesn’t remember consent from one page to the next.
- Keep the tracking script on the page. The recorder starts from its page view, and records or counts nothing without it.
- Tell visitors in your privacy notice. Recording’s Text for your privacy page and consent banner follows your settings. Adapt it, and check it with whoever looks after your privacy terms.
When recording starts
Add the recorder offers two tags. The choice only changes the tag it shows you; the tag on your pages decides.
data-consent="wait", and nothing is recorded or counted until your banner runs the line above, unless Count before consent is on (below), which counts heatmaps before it.<script defer src="https://app.lyli.io/r.js" data-site="s_k3m9x2p7qa"></script>Count before consent
In Replays and heatmaps, under the Heatmaps switch, Count before consent counts clicks and scrolling on every page view before the visitor agrees. Replays still wait. Turning it on asks first; once saved, it applies from the next page view.
Only where the law lets you count without consent. This mainly fits the UK’s statistics exception. Elsewhere, assume you need consent unless your adviser says otherwise. Where it fits, it holds only if you tell visitors in your privacy notice that you count them, and give them a free, simple way to object: the opt-out below.
- The Heatmaps report says which it counts: every visitor, or only those who agreed.
- The picture a heatmap is drawn over still comes only from a visit that agreed to be recorded.
- Turn it off, and from then on we keep no counts sent before consent; counts already kept stay in the heatmap.
If a visitor changes their mind
Have your banner run the line below. Its call stops the recording and the counting at once and drops what hadn’t been sent yet, and setting the flag to false stops e.js too (below). On a page where the recorder isn’t loaded, the call does nothing, so it can’t break your banner. On later pages, don’t run the consent line again. Setting window.lyliConsent = false alone doesn’t stop the recorder.
window.lyliConsent = false; window.lyli?.stopRecording?.();A replay already sent stays until its days are up; an admin can delete it sooner from the replay’s page with Delete this replay…. Heatmap counts aren’t tied to the visit and stay with the site’s counts, and a heatmap picture taken from the visit stays its 30 days, unless it came from the replay you delete.
Let visitors opt out
Opting out covers more than the recorder: it stops everything we collect in that browser on your site, including page views, heatmaps, and replays, and a recording under way stops at once. Put a link on your privacy page, or call it from your own switch.
<a href="#" data-lyli-opt-out>Opt out of analytics and recording</a>lyli.optOut(); // and lyli.optIn() to undo itThe script makes the link a switch: once used, it reads “You’ve opted out · Opt back in.” The choice is kept in the visitor’s browser for your site only, not in a cookie, and nothing is sent once they’ve opted out. Where the browser keeps nothing, it holds for that page only, and the link says so. The link and lyli.optOut() come with the recorder and with e.js; on a page with only the tracking script, see Exclude your own visits.
Errors wait the same way
Errors has its own script, e.js, set up in Settings › Errors. Under When e.js starts, Wait for consent is the default: its tag carries data-consent="wait", and nothing is sent until your banner says the visitor agreed. In the EU and UK, assume error capture needs consent too.
window.lyliConsent = true; window.lyli?.record?.(); window.lyli?.errors?.();window.lyliConsent = true; window.lyli?.record?.();window.lyliConsent = true; window.lyli?.errors?.();- Both scripts read the same
window.lyliConsent, so with the recorder and e.js both on your pages, run both calls in one place. - Unlike the recorder, e.js stops again when
window.lyliConsentis set tofalse. - Capture without asking sends errors before consent, and asks first. Choose it only if your adviser agrees, and then tell visitors in your privacy notice and give them the opt-out. Without it, we keep no error report e.js sent before consent.

