Integrations
HotjarHotjar
preset documentationDocumentation

CookiePilot Hotjar preset: _hj cookies, heatmaps and session replay after consent

Hotjar may belong to analytics or preferences depending on how you use heatmaps and session recordings. CookiePilot helps hold _hj cookies and the Hotjar script until the right consent is granted.

Consent behaviour

Category: analytics or preferences.

Common cookies: _hjSession, _hjSessionUser.

Session replay needs careful privacy configuration.

Setup steps

Assign Hotjar to analytics or preferences according to your policy.

Do not load the script before that category is granted.

Test forms and pages with sensitive data.

Example snippet

Example snippet
<script>
window.addEventListener('cookiepilot:consent', function (event) {
  var consent = event.detail || {};
  if (!(consent.analytics || consent.preferences) || window.__hotjarLoaded) return;
  window.__hotjarLoaded = true;

  (function(h,o,t,j,a,r){
    h.hj=h.hj||function(){(h.hj.q=h.hj.q||[]).push(arguments)};
    h._hjSettings={hjid: HOTJAR_SITE_ID, hjsv: 6};
    a=o.getElementsByTagName('head')[0];
    r=o.createElement('script');r.async=1;
    r.src=t+h._hjSettings.hjid+j+h._hjSettings.hjsv;
    a.appendChild(r);
  })(window,document,'https://static.hotjar.com/c/hotjar-','.js?sv=');
});
</script>

Test checklist

No _hj before consent.

After Reject, no static.hotjar.com.

Field masking works where needed.

Related integrations

See the setups that most often appear together with this integration.

Ready to configure it?

Start CookiePilot, choose the right integration and verify that tags wait for user consent before they run.