Page snapshots
How the backdrop of a heatmap is captured, what the preview's status strip says, and the limits of the replay.
The backdrop of a heatmap on Pages & heatmaps is a snapshot of the page. The tracker captures it in a visitor's browser, and the console replays it. The backdrop is not the live site in a frame. Most production sites refuse to be framed, through X-Frame-Options or a CSP frame-ancestors that Nginx, Cloudflare, Helmet and framework templates set by default. A refused frame gives the console no signal at all, only a blank panel.
What is and is not captured lists what a capture keeps, drops and masks.
How a snapshot is made
A snapshot goes through four stages:
- Opt-in, per website. Snapshots store page content, which nothing else in the module does. They are off until you enable them for the site. The Page snapshots switch is on the General tab of the website's settings on the Websites page, with what enabling it stores. The preview always shows the state and links there with Snapshot settings. While snapshots are off, its status strip offers Enable page snapshots. Once they are on, its status line says what is masked. The preview's More menu holds both options, Page snapshots and Mask all text, as a shortcut. Over the API, the fields are
snapshotsEnabledandsnapshotMaskTexton the website (PUT /api/marketing/websites/:id). - Negotiated capture. A capture happens only on a visit already sampled for clicks, by the same draw, 10% of page loads by default. Once the page has loaded and gone idle, the tracker asks the backend whether it wants a capture of this path at this layout. The backend wants one when none exists or the existing one is older than a day. It then answers with the capture script itself, and otherwise with nothing. The first sampled visit of a page captures it, and a busy page is captured about once a day. No visit uploads a capture that the backend would discard. A page whose snapshot was removed, by a reset, an option change or the retention, is captured again at its next sampled visit. On a deployment of several instances, that takes up to 5 minutes. An upload the backend refused does not count as a capture. A capture taken before captures marked the scroll root of an app-shell page is replaced at the next sampled visit too, see Pages that scroll an inner panel.
- Serialization in the visitor's browser. The capture serializes the rendered DOM into one self-contained HTML document. The rendered DOM is what the visitor sees, whatever built it, client-rendered SPAs included. The capture inlines same-origin stylesheets from the CSSOM, CSS-in-JS included. It makes URLs absolute, leaves cross-origin stylesheets as links, and emits open shadow roots as declarative shadow DOM. Upload size is covered by Retention and size.
- Replay. The console renders the document in a sandboxed frame. No script runs in it, and nothing in it can be clicked, hovered or navigated, because a stray click would take the backdrop to a page the numbers are not about. The console reads the frame's geometry to place anchored clicks. To use the real page, choose Open in the preview's More menu, or the icon beside the path. It opens a new tab on the origin the snapshot was captured on.
The capture inlines only the CSS the page uses:
- It keeps a style rule when its selector matches an element of the captured page. The test treats the element as hovered, focused or open, and takes the pseudo-element off, so
:hover,::beforeand similar rules keep their style. It keeps a rule whenever the browser cannot test it. - It drops custom properties that nothing refers to.
- It keeps
@media,@supports,@containerand@layeraround the rules they still hold, for every layout. It keeps@font-face,@keyframesand@property. - It does not repeat a stylesheet identical to one already inlined.
The browser gzips the upload where it has CompressionStream, which every current browser has, and sends plain JSON otherwise. The capture runs after the DOM has gone quiet, in idle time, so the visitor's page never waits for it.
A page the tracker cannot capture has counts but no backdrop. Examples are a page not online yet, or a page whose clicks came from imported history. A project can declare a snapshot from code with EnsurePageSnapshot, see Extending. The module sanitizes the document like a capture and shows it the same way. The first capture of the live page, a day or more later, replaces it.
One snapshot per layout
The module keeps one snapshot per website, path and layout. The layout is the visitor's viewport width, bucketed as desktop (1024 px and more), tablet (600 px and more) or phone. When you ask for a layout that no visitor has been captured at, the preview reflows the nearest one at that width, and the status strip says so. Anchored clicks still land on their element.
The numbers never depend on the snapshot. Points and totals come from the database, and the snapshot is only the surface they are drawn on. Without a backdrop, the preview draws nothing. This happens when snapshots are off for the site, when no sampled visit has captured the page yet, or when the page is too heavy to capture. The click and scroll counts stay in the header, and the status strip says why there is no backdrop and when there will be one. With a backdrop, a status line under the toolbar reads Snapshot captured 3 Nov · desktop 1280px. It names the page the snapshot was taken from, as origin and path (from https://shop.example/pricing), never with a query string. It also says what is masked.
The status strip
When something needs attention, the preview shows one strip under its toolbar, the one with the highest priority, with its own action where there is one. In priority order:
- Collection is off. The tracker is switched off in the module settings. The strip links to them.
- Page snapshots are off for this site. The strip offers Enable page snapshots.
- No snapshot of this page yet. The next sampled visit captures one.
- Page too heavy to capture. See Retention and size.
- N% of clicks aim at elements missing from this snapshot, on the clicks overlay only. The page has probably changed since the capture. The share is weighted over the clicks that carry an element anchor. A click counts as missing when its selector and rank match no element of the snapshot document, and the overlay then draws it at its document fraction. The strip shows from 10% of the anchored clicks and at least 5 missing clicks. An element that is in the snapshot but not drawn at the chosen width, such as a phone-only menu on the desktop layout, does not count. The strip stays on one line so the snapshot keeps its room. Its explanation sits behind its info button. Its action, Reset this page…, clears the page's clicks and snapshot so both start again from the current version. Closing the strip hides it for that page until the console reloads, and the next strip that applies, if any, takes its place.
- Partial heatmap or Partial scroll depth. The page recorded more clicks or scrolls than one read covers. Narrow the period.
- Page too tall to preview accurately. The document exceeds the largest surface the browser draws, so the overlay and the backdrop no longer line up. The figures are not affected.
- Showing the desktop snapshot at 768px, for example. No visitor has been captured at the chosen width, so the preview reflows the nearest snapshot.
- Page wider than the chosen layout. The backdrop may be cut off. The overlay follows the document and stays aligned.
Retention and size
Snapshots have their own retention, Page snapshots (days) in Settings. It is 30 days by default and never longer than the raw events retention. While the page keeps being visited, its snapshots are replaced daily. They are deleted with a heatmap reset, with the website, and with the workspace. A website keeps at most 1000 snapshots, and a page past that cap gets no backdrop.
A capture upload is at most 1 MiB by default, compressed. The snapshotMaxBytes option (Configuration) moves the cap between 64 KiB and 8 MiB. The cap covers the HTML and the CSS the page uses, never the images, videos or fonts. Those stay URLs that the console loads from your site.
When a capture comes out past the cap, the browser uploads its size instead of the document. The page then has no backdrop, and the strip gives the size of the last capture against the cap, for example 1.4 MiB against 1 MiB. The click and scroll figures stay as they are, and a visit retries the capture daily. To bring a page under the cap, use one of these:
- Trim the markup, for example a table of thousands of rows.
- Wrap the heavy part in
data-dms-marketing-block, which keeps its box and drops its content. - Raise
snapshotMaxBytes.
Markup is what overshoots the cap, so it is rare. Unused CSS is left out and the upload is compressed. A dashboard page in development, with Tailwind, a component library and every module layer loaded, has about 870 KB of CSS and uploads in about 50 KB.
Limits of the replay
The replay differs from the live page in these cases:
- Viewport-relative sizes. The frame is as tall as the whole page, so inside it
100vhwould be the page, not a screen. Before rendering, the console rewritesvh,svh,lvh,dvh,vminandvmaxin the captured stylesheets to the pixels they had in the visitor's viewport. A stylesheet the capture could not inline, because it is cross-origin, keeps them. A media query on the viewport height still sees the frame's height. - Late content. Data fetched long after load, infinite scroll and sections rendered lazily below the fold are missing, or in their loading state, if they had not arrived when the DOM went quiet.
- Fonts and cross-origin styles. A stylesheet the browser refuses to read, because it is cross-origin, stays a link that the admin's browser fetches. A font served without CORS headers falls back to the default font.
- The console's own CSP. The frame inherits it. A deployment that restricts
img-srcorstyle-srcon the console loses the backdrop's images or styles, never its structure.
Pages that scroll an inner panel
An app shell, such as a dashboard or a sidebar layout, often keeps its document still and scrolls a container inside it. The tracker measures scroll depth and click positions on that container, and the capture marks it. The backdrop is then unrolled to the whole content and scrolls to the bottom of the page. Tracker & custom events says which container counts and how to name it yourself. Snapshots taken before the capture marked the container carry no mark and still show the first screen only. When the tracker sees a page scroll an inner container, its next sampled visit replaces that snapshot without waiting for the daily refresh.