Heatmaps
Click heatmaps, rage and dead clicks, and scroll maps per page and screen size, without recording what people type or read.
Heatmaps show where visitors click on a page and how far down they scroll. They come from a small tracker module, separate from session replay: it records positions and a short CSS path for each click, never the page's text.
Turn it on
Add data-heatmap to your script tag. The core then loads e-heatmap.js from the same folder.
<script defer data-site="SITE_ID" data-heatmap src="https://stancelens.com/e.js"></script>Clicks wait in the browser and are sent in batches of up to 30 when the visitor leaves or hides the page, moves to another page of a single-page app, or has made 30 clicks. Each click and each page's scroll depth is stored as an event, so they count toward your monthly events.
What is recorded
| Event | Properties |
|---|---|
$click | sel CSS path of the clicked element, x and y position on the page, ex and ey position inside the element, bw and bh element size, vw viewport width, dh page height, rage, dead |
$scrollmap | depth how far the bottom of the screen got, in % of the page; vw, vh viewport size; dh page height. One per page view (again only if the visitor scrolled further). |
- A click on an icon or text inside a link, button, form field,
summaryor[role=button]counts as a click on that element. - The CSS path has up to five levels of tag names,
:nth-of-type(), and ids and class names. An id or class name is only used if it starts with a letter, is at most 32 letters, digits,-or_, and has at most 3 digits, so emails, tokens and generated ids are left out. - Rage click: the third click within 700 ms of the one before it and 30 px of the first. A burst counts once.
- Dead click: nothing on the page changed within a second (no change to the page's elements, attributes or text, and no navigation). Clicks on form fields are never dead clicks.
What is never recorded
- Text on the page, input values, link targets, image sources, titles, labels or any attribute other than safe-looking ids and class names.
- Mouse movement, hovering or keystrokes.
- Clicks inside an element with
data-el-ignore(or any of its children).
Pages that match data-exclude, visitors with localStorage.stancelens_ignore, and (with data-respect-dnt) visitors with Do Not Track or Global Privacy Control send nothing, as with every other module.
Reading a heatmap
Open Heatmaps in the dashboard and pick a page. The page list shows pages with heatmap data in the selected period, most clicked first; the period, filters and site time zone work as on every other page. A Page filter narrows the list, and an Event filter is ignored.
- Screen size: mobile (viewport under 768 px wide), tablet (768 to 1023 px) and desktop (1024 px and wider), from the viewport width at the time of the click, not the device type.
- Clicks: click density over the page, the most clicked elements (grouped by CSS path, so they hold when the layout moves) with their rage and dead clicks.
- Scroll: the share of visitors who reached each 10% of the page, using each visitor's deepest view, and the median fold (the bottom of the first screen).
Live page or outline
The heatmap is drawn over your live page, loaded at the median viewport width of the visitors with that screen size. The dashboard first checks your page's X-Frame-Options and Content-Security-Policy: frame-ancestors headers. If they don't allow it to be framed, the address isn't public, or the page doesn't load within 10 seconds, the heatmap is drawn on an outline of the clicked elements instead.
To allow the live view, let the dashboard's origin frame your pages, for example Content-Security-Policy: frame-ancestors 'self' https://stancelens.com. The page loads in a sandbox with scripts turned off, so pages that render only in JavaScript show up blank (switch to Outline above the heatmap), and your own tracker doesn't count the view. The live view is your page as it is now; the clicks were recorded on the versions visitors saw.