Session replay scripts record what a visitor types, clicks and sees, then send it to a third party, and unless masking is configured page by page they capture far more personal data than the product team intended. Heatmaps built from the same scripts carry a smaller but real version of the risk. This guide explains how session replay and heatmap tools collect data, what ends up in recordings, how to mask and exclude sensitive content, when consent is needed under the ePrivacy rules in the EU and PECR in the UK, and what to check before choosing or renewing a supplier. It is written for product, web engineering and privacy teams who own or approve these tools, and it stays vendor-neutral.
Key takeaways
- Recordings capture the page, not just clicks. Replay tools serialise the page and every change to it, so anything displayed (names, order details, health information) is captured unless it is masked.
- Default masking usually covers password fields only. The open-source rrweb recorder, for example, masks password inputs by default and leaves other inputs and on-screen text unmasked unless configured; check each supplier's documented defaults.
- Individual recordings need consent in the UK. The ICO's 2026 guidance says logs or recordings of individual visitors and their actions are not covered by the new statistical purposes exception; aggregate measures such as average scroll depth may be.
- EU law treats the script itself as access to the device. EDPB Guidelines 2/2023 say client-side JavaScript that instructs the browser to send information is gaining access under Article 5(3) of the ePrivacy Directive, so the consent analysis applies before any cookie is set.
- The supplier is a processor holding your users' sessions. Contract terms, retention, region, access controls on the replay dashboard and onward transfers all need checking, and a DPIA is the right place to record the decision.
How session replay works
A replay script loads on the page and takes a snapshot of the document object model (DOM): the structure, text and attributes of the page as the browser rendered it. It then records every mutation to the DOM, together with mouse movement, clicks, scrolls, viewport changes and input events, each with a timestamp. The supplier's player rebuilds the page from these events and plays it back like a video. Nothing is filmed; the recording is structured data, which is why masking can be applied before data leaves the browser, and why unmasked text arrives in readable form.
The open-source rrweb library documents the mechanics plainly: an initial full snapshot, incremental events after it, optional periodic full snapshots (checkout), and options for recording canvas elements and cross-origin iframes, both off by default. Commercial tools add features on top: console and network logging, error capture, rage-click detection and user identification that links a recording to an account ID.
Heatmaps aggregate the same click, move and scroll events across many visitors to show where attention lands. Some tools build heatmaps from the replay stream itself, so turning on heatmaps can mean recording individual sessions in the background. Ask the supplier which it is.
| Tool mode | What is collected | Identifiability | Privacy weight |
|---|---|---|---|
| Aggregate heatmap (counts only) | Click and scroll positions per page, summed | Low if no identifiers are kept at individual level | Lowest; may fit analytics exemptions |
| Heatmap built from recordings | Full event stream per visitor, aggregated for display | Individual records exist | Same as session replay |
| Session replay, anonymous | DOM, inputs, movement per visit, device and IP data | Often identifiable from content shown or typed | High |
| Session replay, identified | As above, linked to account ID or email | Directly identifiable | Highest |
| Replay with console and network capture | Adds API requests, responses and logs | Can include tokens and personal data in payloads | Highest, plus a security risk |
What data gets captured
The data problem is well documented. A 2017 Princeton study found session replay scripts on 482 of the Alexa top 50,000 sites, and showed recordings capturing typed text on registration forms that were never submitted, payment card details where fields lacked the expected attributes, and prescription and health details displayed on screen alongside names. The researchers found that no supplier they tested redacted displayed content by default. Tools have improved since, but the underlying design is the same: what is not masked is sent.
| Data source | Examples | Captured by default? | Required control |
|---|---|---|---|
| Password inputs | input type="password" | Usually masked | Confirm; also mask password fields rendered as plain text inputs |
| Other form inputs | Names, addresses, card numbers, national ID numbers, free-text messages | Varies by supplier; often captured unless configured | Mask all inputs, then unmask named safe fields |
| Displayed text | Account names, order history, balances, medical or benefits data, search results | Commonly captured | Mask text on authenticated pages; block whole regions |
| URLs and query strings | Email addresses, tokens or search terms in parameters | Captured | Strip or hash parameters before sending |
| Images and canvas | Scanned documents, signatures, ID uploads | Image references usually; canvas varies | Block upload and preview components |
| Console and network logs | API responses, session tokens, error messages with personal data | Off unless enabled | Leave off, or allowlist headers and redact bodies |
| Device and network data | IP address, user agent, screen size, location | Captured | Truncate IP, set retention |
Special category data under UK and EU GDPR (health, religion, sexual orientation) often appears on screen in sectors that do not think of themselves as handling it: pharmacy, insurance, charities, dating and recruitment. Payment pages raise a separate problem: PCI DSS v4.0 requirement 6.4.3 requires every script on a payment page to be authorised, justified and integrity-checked, and requirement 11.6.1 requires detection of unauthorised changes to payment pages. A replay script on checkout is in scope for both. See the PCI DSS 4.0 Guide and the Client-Side Security Guide.
Masking and exclusion
Masking replaces content with placeholder characters in the browser before transmission. Blocking excludes an element entirely and replays it as an empty box of the same size. Ignoring stops input events from an element being recorded. Server-side redaction after receipt is weaker, because the supplier has already received the data. rrweb's documented privacy options show the typical controls: a block class (rr-block), an ignore class (rr-ignore), a mask-text class (rr-mask), maskAllInputs (false by default), and maskInputOptions, which masks password inputs by default. Commercial tools use similar class names, data attributes or CSS selectors.
Approaches compared
| Approach | How it works | Strength | Weakness |
|---|---|---|---|
| Mask by default (allowlist) | All text and inputs masked; named safe elements unmasked | New fields and pages are safe automatically | Recordings are less readable; needs a review process for unmasking |
| Capture by default (blocklist) | Everything captured; sensitive elements tagged for masking | Readable recordings | Every new field or page is a potential leak |
| Page-level exclusion | Script not loaded on listed paths | Nothing leaves sensitive pages | Depends on path rules staying current |
| Server-side redaction | Supplier removes patterns after receipt | Catches some misses | Data has already left your control |
Implementation steps
- Decide where the script may run: keep it off login, password reset, checkout and payment, account settings, identity verification, support chat and any page showing special category data. Enforce this in the tag manager or build, not by convention; the Google Tag Manager Security guide covers tag governance.
- Turn on mask-all: mask all inputs and all text on authenticated pages, then unmask specific elements (navigation labels, button text) through a reviewed list.
- Block components: file uploads, document previews, embedded iframes from payment or identity providers, and any canvas showing user content.
- Strip URLs: remove query strings and fragments, or allowlist parameters that carry no personal data.
- Keep console and network capture off in production unless a specific debugging need is approved, time-limited and redacted.
- Test before release: on a staging site, fill every form with synthetic personal data and canary values, record a session, and search the stored recording and the network traffic for the canaries. Add this check to release testing for templates that change.
- Roll back: keep a single switch (tag pause or feature flag) that stops the script everywhere within minutes, and a supplier procedure to delete recordings captured by mistake.
The aim is data minimisation in practice: collect the interaction pattern the product team needs, not the content. See Data Minimisation and the Privacy by Design Guide for Engineering Teams.
Consent and legal basis
Two layers of law apply. The device-access rule (Article 5(3) of the ePrivacy Directive in the EU, regulation 6 of PECR in the UK) decides whether you need consent to run the script and store or read data on the device. Data protection law (UK GDPR and EU GDPR) then governs the personal data in the recordings.
| Question | EU (ePrivacy Directive, EDPB, CNIL) | UK (PECR as amended, ICO) |
|---|---|---|
| Is the script covered? | Yes. EDPB Guidelines 2/2023 (version 2.0, adopted 7 October 2024) treat JavaScript that instructs the browser to send information as gaining access, and cover non-personal information too | Yes. The ICO guidance covers cookies, pixels, web storage, fingerprinting and scripts or tags |
| Exemption for analytics? | Only the strictly necessary and transmission exemptions in Article 5(3); national regulators may treat narrowly configured audience measurement as exempt (CNIL: limited to audience measurement and A/B testing, single site, no cross-checking, IP truncation, trackers limited to 13 months, right to object) | Statistical purposes exception: sole purpose is statistics about how the service is used, to improve it, aggregate results, clear information and a free, simple means to object; a third party may help only as a processor that does not link the data |
| Session replay | Not named by the EDPB; it records individual behaviour and goes beyond audience measurement, so plan for consent | The ICO says logs or recordings of individual visitors and their actions need consent unless collected for security purposes |
| Aggregate heatmaps | Possibly within a national audience measurement exemption if configured to its conditions | The ICO lists aggregate measures such as average scroll depth as likely to meet the statistical exception |
The UK position is recent. The ICO published its storage and access technologies guidance in December 2024, issued draft changes in July 2025 after the Data (Use and Access) Act 2025 amended PECR, and its current guidance pages are dated 29 April 2026. Check the current text before relying on the statistical exception. See the PECR Guide and the UK Data Act 2025 Guide.
Consent in practice: load the replay script only after an affirmative choice in the consent banner, as a separate purpose from general analytics, and stop recording when consent is withdrawn. Pre-ticked boxes and "continue browsing" do not count. The Consent Management Guide: Cookies, CMPs and GPC covers banner design and signals.
GDPR lawful basis: once consent is the device-access basis, most organisations also rely on consent for the recording itself. Record the purpose, retention and masking configuration, and run a DPIA where recordings cover authenticated users, special category data or large volumes; see the DPIA Guide: Running a Data Protection Impact Assessment. Recordings are personal data, so they fall within subject access and erasure requests: confirm the supplier can find and delete a user's sessions by identifier.
Vendor and data residency checks
A replay supplier receives a stream of your users' sessions, so treat it like any processor handling customer data. The Data Processor Due Diligence Questionnaire Template gives a full question set; the checks specific to replay tools are:
- Processor role: the contract must make the supplier a processor under Article 28 that uses recordings only for your purposes, with no use to train its own models or build cross-customer profiles. Under the UK statistical exception, a provider that links data with other information it holds takes you outside the exception. See the GDPR Article 28 Processor Guide.
- Masking defaults and enforcement: documented defaults for inputs and text, whether masking happens in the browser, and whether admins can enforce mask-all across projects.
- Region and transfers: where recordings are stored and processed, sub-processors, and the transfer mechanism for any processing outside the UK or EEA.
- Retention and deletion: configurable retention, deletion by user identifier, and deletion of a whole time range when a masking mistake is found.
- Dashboard access: SSO with MFA, role-based access to recordings, audit logs of who viewed which session, and export controls. The replay dashboard is a store of customer sessions; see the SaaS and OAuth App Governance Guide for the API keys and integrations around it.
- Script delivery: served over HTTPS from a stable origin, compatible with your Content Security Policy and subresource integrity where the supplier supports versioned scripts; see the Content Security Policy Guide.
Small organisations may find that aggregate analytics without replay answer most product questions with far less compliance work. Larger organisations with dedicated research teams can justify replay, but usually on a sample of consenting users and a defined set of pages rather than site-wide.
Detection and measurement
- Canary leak rate: share of release tests in which a canary value appears in a recording (target zero).
- Coverage of exclusions: sensitive page templates where the script is confirmed absent, checked by an automated crawl.
- Consent gating: sessions recorded without a matching consent record (target zero), sampled from consent logs and supplier data.
- Retention compliance: oldest recording held compared with the configured retention period.
- Access review: named users with replay access, reviewed quarterly, and views per user from the supplier audit log.
Framework mapping
| Framework | Reference | Relevance |
|---|---|---|
| UK and EU GDPR | Art. 5(1)(c) data minimisation; Art. 25 data protection by design and by default; Art. 28 processors; Art. 35 DPIA | Masking defaults, processor contract, risk assessment |
| NIST SP 800-53 Rev 5 | PT-3 PII Processing Purposes; PT-4 Consent; PT-5 Privacy Notice; SA-8(33) Minimization; SA-9 External System Services | Purpose limits, consent gating, notices, supplier oversight |
| NIST CSF 2.0 | GV.OC-03; GV.SC-07; PR.DS-01 | Legal requirements, supplier risk, protecting stored recordings |
| ISO/IEC 27001:2022 Annex A | A.5.19 Information security in supplier relationships; A.5.34 Privacy and protection of PII; A.8.11 Data masking | Supplier controls, PII handling, masking |
| PCI DSS v4.0 | 6.4.3; 11.6.1 | Scripts on payment pages |
Common failure patterns
- Trusting default masking: only password fields are masked, so addresses, card numbers typed into custom fields and free-text messages are recorded.
- Masking inputs but not displayed text: the account page shows the customer's name, address and order history, and it all appears in the replay.
- Loading the script before consent: the tag fires on page load and the banner only sets a flag, so recording starts before the visitor has chosen.
- Script left on sensitive templates: a new checkout or identity verification flow ships with the site-wide tag still attached.
- Network capture switched on for debugging and never switched off: API responses with personal data and session tokens are stored by the supplier.
- Replay access left wide open: every product, marketing and contractor account can watch customer sessions, with no view logging.
Practitioner checklist
- List every page and app where replay or heatmap scripts run, and which supplier and mode each uses.
- Remove the script from login, payment, account settings, identity verification and special category pages.
- Enable mask-all for inputs and text, and manage unmasking through a reviewed allowlist.
- Strip query strings, block uploads and iframes, and keep console and network capture off.
- Gate session replay on a separate consent purpose and stop recording on withdrawal.
- Use aggregate heatmaps where they meet the question, and confirm they are not built from stored recordings.
- Complete a DPIA and an Article 28 contract covering region, retention, deletion and no secondary use.
- Run canary tests in release testing and an automated crawl to confirm exclusions.
- Protect the replay dashboard with SSO, MFA, role-based access and view logging.
Standards and references
- ICO: Guidance on the use of storage and access technologies
- ICO: What are the exceptions?
- EDPB: Guidelines 2/2023 on the technical scope of Art. 5(3) of the ePrivacy Directive
- CNIL: Use analytics on your websites and applications
- Princeton CITP: No boundaries: exfiltration of personal data by session-replay scripts
- rrweb: Guide (recording options and privacy)
Related NHI Mgmt Group resources: Cookie and Tracking Technology Compliance Guide · ePrivacy Directive Guide · Client-Side Security Guide · DPIA Guide: Running a Data Protection Impact Assessment