Session replay is an analytics technique that reconstructs what a visitor saw and did on a website by recording the page's structure and the stream of events that changed it. Instead of a chart showing that 40 percent of users abandoned a checkout form, a product team can watch a reconstruction of one visitor scrolling, hesitating over a field, typing, deleting and leaving. In many web implementations, the recording is not a screen video. It combines a serialised copy of the page's Document Object Model, or DOM, plus a timeline of mutations, mouse movements, scrolls and inputs that a player uses to rebuild the page as it evolved. This matters for privacy: text and interaction data may be captured unless the recorder excludes or masks them before transmission.
Capturing Events and Page State
A session recording script runs inside the page alongside the site's own code. When the page loads, the script walks the DOM and produces a snapshot: the included elements, attributes and text nodes, serialised into a data structure with a unique identifier for each node. The open-source rrweb library, which several commercial tools build on, describes this as converting the DOM and its state into a serialisable form that can later be turned back into real elements.
After the initial snapshot, the recorder listens for changes rather than taking repeated pictures. A mutation observer reports nodes added, removed or edited. Event listeners capture mouse position, clicks, scroll offsets, viewport resizes and the contents of form fields as they change. Each observation becomes a small timestamped event sent to a collection endpoint, often in batches. Because only differences are transmitted, the format can be more compact than screen video, although a rapidly changing page can still generate substantial data, and the result stays searchable: an analyst can look for every session in which a particular button was clicked, since the click event references the node's identifier rather than pixel coordinates in a picture.
Reconstructing a Session
DOM replay is the reverse process. A player loads the initial snapshot into a sandboxed frame, rebuilding the elements from the serialised description, then applies the recorded events in order and at their original timing. Text that changed appears to change; the recorded mouse path is drawn as a moving cursor; scroll events move the viewport. Stylesheets and images are usually fetched from their original URLs or from a stored copy, so a replay of an old session can look slightly different if the site's CSS has since changed. Periodic full snapshots let the player seek to a later point without replaying every event from the start.
The reconstruction is faithful to the structure, not to the pixels. Fonts installed on the analyst's machine, browser rendering differences and missing third-party resources can all cause small visual deviations. Script execution is normally blocked in the player, so interactive widgets show their recorded state rather than running again. In exchange, the format is compact and inspectable, which is why analytics session replay has become a standard companion to heatmaps and funnel reports.
Masking, Consent and Retention
Everything visible in the DOM is a candidate for capture, including names, addresses, account balances and message text. Replay privacy masking is the set of controls that prevent such content from being recorded in the first place. rrweb masks password fields by default, offers an option to mask all input content, and lets developers mark elements by class so that their text is replaced with placeholder characters or so that the element is blocked from recording entirely and replays as an empty box. Microsoft Clarity documents three site-wide modes, from masking all text to masking only numbers and email addresses, and states that input boxes and drop-down menus are masked in every mode. Clarity also notes that masked content is never uploaded, that masking changes apply only to new recordings, and that content inside style sheets is not masked.
Two consequences follow. Masking must happen in the browser before transmission, because later display masking cannot undo its earlier disclosure. Deleting stored recordings and derived data may still be possible, depending on the system’s controls and retention. And masking rules must be reviewed when the page changes, since a new sensitive element can escape narrowly targeted masking rules. A default that masks all text and inputs reduces that risk, but still needs testing. Beyond masking, teams should decide how long recordings are retained, who may view them and whether the applicable consent framework treats replay as analytics that needs user agreement. The vendor’s data-protection role depends on its contract and actual processing, rather than the tool’s label alone.
Replay Analytics vs Token Replay Attacks
The phrase is shared with a security concept that has nothing to do with analytics. In a replay attack, an attacker captures a valid message, such as an authentication token or a signed request, and submits it again to be accepted as legitimate. Session hijacking, in the same family, means taking over someone's live authenticated session by obtaining its identifier. Analytics session replay reconstructs an interface for analysis; it is not designed to resubmit authenticated actions. However, a recorder can accidentally collect credentials or tokens exposed in page content, URLs or optional network capture. The analytics label does not guarantee that its data is non-sensitive.
| Aspect | Analytics session replay | Token or request replay attack |
|---|---|---|
| What is captured | DOM snapshots and interaction events | A valid token, cookie or signed message |
| Who captures it | The site operator's analytics script | An attacker obtaining reusable messages or credentials |
| Purpose | Understand and improve the interface | Impersonate a user to a server |
| Defence | Masking, consent, retention limits | Expiring tokens, nonces, TLS, session renewal |
The overlap is indirect but real. A replay recording that captured an unmasked session identifier shown on screen, or the contents of a password field, would create a trove that an attacker could use later. Good masking therefore serves security as well as privacy.
Uses and Limitations
Replay is most valuable for diagnosing specific problems: a form that users repeatedly fail to submit, an error message that appears without obvious cause, or a layout that breaks on one browser. A focused sample can reveal an interaction sequence missing from aggregate metrics. Support teams can compare the reconstruction with an error report, while remembering that missing assets or capture gaps may change what the player shows.
Its limits are equally concrete. Recording scripts perform work in the page and transmit collected events, which can affect performance on slow devices. Sampling is common, so not every session exists to be replayed. Canvas, cross-origin frames and media may be absent or need separate recording support, which adds cost and privacy considerations. And the technique tells you what happened, not why: a hesitation over a field may mean confusion, a phone call or a cat. Replay is evidence to be interpreted alongside other signals, not a transcript of the visitor's intent.