Skip to content
FunnelGuard

Fix guide by FunnelsGuard

Session recording loading before consent: how to find and fix it

TRK-241Medium impactPartlyBy FunnelGuardPublished Updated
On this page

What this issue is

Session recording tools (Hotjar, Microsoft Clarity and similar) replay what visitors do on your pages: clicks, scrolls, typing and mouse movement. To do that they load a script and set cookies or local storage in the browser. In many privacy regimes, including the EU and UK, that needs the visitor's consent first.

Why it costs you leads or sales

The cost is mostly risk and trust rather than a broken page. Recording people without a valid consent can expose you to complaints and regulator action, and it can break promises in your own privacy policy. Agencies can put client contracts at risk too.

Where consent gets skipped
  1. Page loadsHeader scripts start
  2. Recording script loadsHotjar or Clarity starts at once
  3. Banner shownVisitor has not answered yet
  4. Visitor rejectsRecording is already running

The recording script starts at page load, before the banner is answered.

How to check if your site has it

Test with a clean browser
  1. Open a private window

    Use a fresh incognito or private window so no earlier consent choice is saved. Do not click anything on the banner yet.

  2. Open DevTools Network tab

    Press F12, open Network, tick 'Preserve log', then load your page. Filter for 'hotjar', 'clarity' or your tool's domain.

  3. Look for requests before you answer the banner

    If requests to static.hotjar.com, script.hotjar.com or www.clarity.ms appear before you click anything, the script is loading before consent.

  4. Check cookies and storage

    In the Application tab, look under Cookies and Local Storage for keys starting with _hj or _clck and _clsk.

  5. Repeat after clicking Reject

    Clear site data, load the page, click Reject, and check again. Requests that continue after a rejection are the clearest sign of a problem.

Consent choice vs recording

The recording should wait for the banner answer, not start before it.

How to fix it

The principle is the same everywhere: remove the always-on script and load it only when the visitor grants the right consent category (usually 'analytics' or 'statistics', or 'marketing' depending on your policy). Pick the route that matches how the tool is installed on your site.

Gate session recording behind consent
  1. Remove hard-coded copies

    Delete the Hotjar or Clarity snippet from your theme or site header so GTM is the only place it loads.

  2. Use a consent-aware trigger

    In the recording tag, open Advanced Settings > Consent Settings and require the consent type you use (for example analytics_storage). Better still, fire the tag on a custom event your consent tool pushes after acceptance.

  3. Remove 'All Pages' if it bypasses consent

    If the tag fires on Initialization or All Pages without a consent check, change it so it cannot run until consent is granted.

  4. Test in Preview mode

    Use GTM Preview, deny consent and confirm the tag shows as 'Not fired'. Then accept and confirm it fires once.

Load Microsoft Clarity only after consent (example pattern)javascript
function loadClarity(projectId) {
  if (window.__clarityLoaded) return;
  window.__clarityLoaded = true;
  (function(c,l,a,r,i,t,y){
    c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)};
    t=l.createElement(r);t.async=1;t.src='https://www.clarity.ms/tag/'+i;
    y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y);
  })(window,document,'clarity','script',projectId);
}

// Call this from your consent tool's 'analytics accepted' callback
// and on page load if stored consent already allows analytics.
// loadClarity('YOUR_PROJECT_ID');
Recording script behaviour

Before

  • Script in the header on every page
  • Requests sent before the banner is answered
  • Recording continues after Reject

After

  • Script loads only after analytics consent
  • No recording requests while consent is denied
  • Returning visitors who accepted are recorded as expected

How to confirm it's fixed

Confirmation checks
  • In a fresh private window, no requests to your recording tool appear before you answer the banner
  • After clicking Reject, no recording requests or _hj / _clck cookies appear, even after navigating to a second page
  • After clicking Accept, the script loads once and recording starts
  • A returning visitor who previously rejected is still not recorded
  • A returning visitor who previously accepted is recorded without seeing the banner again
  • The recording tool's dashboard shows no new sessions from your rejected test

How to prevent it happening again

Consent gating tends to break when someone adds a new tag or pastes a snippet in a hurry. A few habits help.

Prevention habits
  • Keep one place where tracking scripts are added (ideally Google Tag Manager) and forbid hard-coded copies
  • Require a consent check on every new analytics or recording tag before publishing
  • Re-run the denied-consent test after theme changes, plugin updates, consent tool changes and site migrations
  • Document which consent category each tool belongs to
  • Review recording tools when your cookie banner provider or policy changes

How FunnelGuard handles this

FunnelGuard detects this issue only partly. When it runs your journey with consent denied, it records the tracking hits sent during the run. What it checks is that variant: the denied run shows hits only if those hits can be parsed, meaning FunnelGuard can recognise and read them as belonging to a known tag or platform.

Consent and the recording tagInteractive
Recording loads before consent

Consent: blocked / denied

  • GA4no hit
  • Google Adsno hit
  • Meta Pixelno hit

The recording script runs even when the visitor rejects cookies, so sessions are captured without consent.

Toggle to see how consent gating changes what the recording tool receives.

Frequently asked questions

Questions people ask

Why is Hotjar loading before the cookie banner?

Usually the Hotjar snippet is hard-coded in your theme header or fires on an All Pages trigger in Google Tag Manager, so it runs at page load. Remove the hard-coded copy and load Hotjar only after the visitor grants the analytics category in your consent tool.

How do I stop Microsoft Clarity recording until consent is given?

Load the Clarity script only after consent, for example from a Google Tag Manager tag with a consent condition or from your consent tool's callback. Check Clarity's current documentation for its consent signal option, then test with consent denied to confirm nothing is sent.

Does session recording need cookie consent?

In many places, including the EU and UK, recording tools that set cookies or storage and track individuals usually need consent. Rules vary by country and tool, so confirm with a privacy adviser. Technically, make sure the script follows whatever choice the visitor made.

How can I check if a script loads before consent?

Open a private window, open DevTools Network with Preserve log on, and load your page without touching the banner. Filter for your tool's domain, such as hotjar or clarity.ms. Any requests before you answer mean it loads before consent.

Does Google Tag Manager consent mode block session recording tools?

Not automatically. Consent mode signals only affect tags that read them, and a third-party recording tag may ignore them. Set Consent Settings on the tag, or fire it from a trigger that waits for a consent event, then test in Preview mode.

Will gating session recording behind consent reduce my data?

Yes, you will only record visitors who accept, so the sample is smaller. That is the correct result of respecting consent. Use recordings to spot patterns rather than to count total traffic.

Can FunnelGuard tell me if session recording loads before consent?

Partly. FunnelGuard runs a variant with consent denied and shows hits only when it can parse them. It does not reliably catch unparsed recording requests or inspect cookies, so verify the rest manually in your browser.

Does FunnelGuard catch this?

Partly

FunnelGuard checks part of this.

How: denied variant shows hits only if parsed.

Stop finding out from your customers

FunnelGuard runs your real forms and checkouts on a schedule, checks the tracking and the leads behind them, and alerts you once, with a screenshot. Try any paid plan free for 3 days.