How can you detect rage clicks and dead clicks without loading a heavy session-replay SDK?
You can detect rage clicks and dead clicks inside under 2 KB of JavaScript by clustering passive pointer clicks within 1,000 ms and a 30 px Euclidean radius, observing only structural DOM attributes for 500 ms on non-interactive clicks via a self-disconnecting MutationObserver, and transmitting compact CSS selector hints rather than full DOM snapshots or form input text.
- Rage click detection needs only a 3-click sliding buffer filtered by 1,000 ms recency and 30 px Euclidean distance.
- Dead click detection watches only 8 structural attributes (class, style, hidden, open, aria-expanded, aria-selected, aria-pressed, data-state) for 500 ms before disconnecting.
- Emitting compact CSS selector hints (tag#id or tag.class1.class2) eliminates video playback privacy risk while pointing engineers straight to the broken JSX or HTML element.
- Normalizing affected visitors by total page visitors ranks broken checkout and pricing flows ahead of noisy high-traffic blog routes.
Why most SaaS teams abandon session replay tools
Session replay products promise effortless UX debugging, yet engineering teams routinely rip them out within six months. Two operational costs kill adoption:
- Performance and network drag: Full DOM serialization (
rrweb-style snapshotters) listens continuously to every DOM mutation across the entire page tree, buffering megabytes of serialized diffs and degrading Interaction to Next Paint (INP) on complex React or Next.js dashboards. - Privacy masking liability: One unmasked input field, billing modal, or customer table leaks sensitive PII into third-party video recordings, forcing constant CSS
data-maskmaintenance before every security audit.
Even worse, engineers rarely have two hours every Friday to watch silent mouse cursors wander across a pricing table. What developers actually need is a ranked list of broken UI selectors and affected user counts.


Inside TrimStats' 3-signal lightweight friction engine
In TrimStats, UI friction tracking is strictly opt-in (data-friction="true" plus the dashboard toggle) and ships inside the exact same 1,964 B gzipped t.js tracker. Instead of recording screens, it measures three deterministic signals using bounded passive listeners.
Bounded browser timing windows keep TrimStats UI friction lightweight
Production millisecond thresholds implemented in packages/tracker/src/index.ts
Every browser observer in t.js is strictly time-bounded and passive, preventing runaway DOM mutation overhead during long SaaS sessions.
Methodology: Exact millisecond thresholds read directly from packages/tracker/src/index.ts and apps/web/lib/content/facts.ts.
View chart data table
| Label | Window duration |
|---|---|
| rAF scroll throttle frame (60 Hz) | ~16 ms |
| Dead-click MutationObserver cap | 500 ms |
| Rage-click 3-click cluster window | 1,000 ms |
| Active dwell threshold (bounce floor) | 10,000 ms |
1. Rage clicks: 3 clicks in 1,000 ms inside a 30 px radius
When a button fails to fire, submits slowly without a loading spinner, or sits behind an invisible overlay, frustrated visitors tap the same spot rapidly. Inside a { passive: true } click listener, t.js keeps a tiny array of recent (t, x, y) tuples, evicting any click older than 1,000 ms, and filters clicks within a 30 px Euclidean radius:
// Cluster 3 rapid clicks inside 1,000 ms and 30 px Euclidean distance
const clustered = clicks.filter(
(c) => Math.hypot(c.x - x, c.y - y) <= 30,
);
if (clustered.length === 3) {
send({ t: 'rage_click', el: selectorHint(el) });
clicks.length = 0;
return;
}
Resetting the click buffer immediately after dispatch guarantees a single frustrated visitor tapping six times produces at most two clean signals rather than a flood of overlapping beacons.
2. Dead clicks: bounded 500 ms structural MutationObserver
Dead clicks happen when a static badge, card header, or pill looks interactive (for example div.annual-savings-pill), enticing visitors to click something with no click handler.
To avoid false positives, t.js first skips clicks inside real interactive elements (a, button, input, select, textarea, label, [role="button"]). On non-interactive elements, it records location.href and window.scrollY, starts a single short-lived MutationObserver watching only 8 structural state attributes, and disconnects immediately on the first DOM change or at 500 ms:
const obs = new MutationObserver(() => {
mutated = true;
obs.disconnect();
});
obs.observe(document.body, {
childList: true,
subtree: true,
attributes: true,
attributeFilter: [
'class', 'style', 'hidden', 'open',
'aria-expanded', 'aria-selected', 'aria-pressed', 'data-state',
],
});
setTimeout(() => {
obs.disconnect();
if (!mutated && location.href === beforeHref && scrollY === beforeY) {
send({ t: 'dead_click', el: selectorHint(el) });
}
}, 500);
Notice what this observer explicitly ignores: characterData text changes, input values, shadow-DOM passwords, and long-lived DOM diff streams. Once 500 ms elapses, memory overhead drops back to zero.
3. Deep scroll reach (90%) with rAF throttling
For content and landing pages, t.js attaches one passive scroll listener throttled with requestAnimationFrame. Once (window.scrollY + window.innerHeight) / document.documentElement.scrollHeight >= 0.9, it sends a single { t: 'scroll', sc: 90 } beacon and short-circuits all future scroll calculations on that route until SPA navigation resets the flag.
Compact CSS selector hints vs DOM snapshots
When a rage click or dead click fires, selectorHint(el) builds a compact identifier (tag#id or tag.class1.class2, capped at 120 characters) without ever touching innerText or form fields. In ClickHouse, TrimStats groups events by (pathname, element_selector, event_type) and ranks them by affected unique visitors.


Turning raw friction clicks into prioritized fixes and alerts
Raw click counts over-index on your highest-traffic landing pages. TrimStats divides affectedVisitors by totalPageVisitors on every route to compute Friction Rate (%).
Normalized friction rate (% of page visitors affected) prioritizes real UX bugs
Seeded acme.dev 30-day workspace matching the UI Friction report screenshot
Dividing affected visitors by total route visitors exposes high-intent leaks on /pricing (6.4%) and /checkout (4.9%) rather than over-weighting homepage traffic.
Methodology: Computed as (affectedVisitors / totalPageVisitors) * 100 in the seeded acme.dev 30-day demo dataset.
View chart data table
| Label | Friction rate |
|---|---|
| /pricing | 6.4% |
| /checkout | 4.9% |
| /signup | 2.8% |
| /features/revenue-attribution | 1.9% |
| /docs/quickstart | 1.8% |
Better still, UI friction plugs straight into TrimStats' automated rolling 7-day anomaly engine. Whenever any page records at least 15 friction clicks in a 7-day UTC window and increases by 50% or more over the prior 7 completed days, the 6-hour background job raises a friction_spike insight automatically and emails your team before a silent deploy regression costs a week of conversions.
Real UX bugs caught faster by selectors than by replay videos
In practice, ranked CSS selector tables resolve three recurring SaaS conversion bugs in minutes rather than hours of video scrubbing:
- Broken checkout buttons (
rage_click): A coupon validation handler throwing an uncaught exception or a disabled submit button with missing error copy produces immediate 3-click bursts onbutton#apply-coupon.btn-ghostorbutton.checkout-submit. - Deceptive static pills (
dead_click): Marketing badges styled like interactive switches (such asdiv.annual-savings-pillnext to a pricing toggle) attract dozens of dead clicks per day. Turning the badge into a working toggle or toning down its button-like border removes immediate pricing confusion. - Mobile layout overlaps (
rage_click+dead_click): Sticky cookie banners, chat launchers, or fixed headers frequently overlap form buttons on 375 px mobile viewports. Filtering the TrimStats report by device type separates mobile-only CSS overlaps from desktop JavaScript bugs in one click.
Enabling UI friction safely on high-value routes
Because friction listeners are strictly opt-in, you control both event quota and instrumentation surface. Enable Track UI friction under Site settings and add data-friction="true" to your script tag on marketing and checkout layouts. Every friction event counts cleanly toward your monthly plan quota while automated bots and webdriver sessions are dropped before ClickHouse ingestion.
Explore the full UI Friction Tracking feature overview or inspect the exact script configuration in UI Friction Docs.
Frequently asked questions
Why does dead-click detection ignore clicks on native buttons and links?
Does enabling data-friction="true" slow down scrolling or click responsiveness?
Can CSS selector hints leak customer PII?
When should a product team still use video session replay instead of lightweight friction selectors?
Does UI friction tracking work on Next.js, React, and Astro single-page apps?
Can TrimStats alert engineering automatically when a deploy introduces a rage-click spike?
Sources & references
- MDN Web Docs: MutationObserver APIAccessed 2026-11-30
- TrimStats UI Friction Technical DocumentationAccessed 2026-11-30
Co-founder of DotCamp LLC in Brooklyn, NY and lead engineer of TrimStats. Ships privacy-first web analytics, ClickHouse pipelines, and WordPress plugins used on 115,000+ active sites.
- • Architect of the TrimStats 1.96 KB gzipped browser tracker, Fastify collector, and ClickHouse MergeTree pipeline
- • Co-founder of DotCamp LLC (est. 2019), creator of Ultimate Blocks (50,000+ installs), WP Table Builder (50,000+ installs), Tableberg, and OptimizeCamp
- • WordPress.org plugin & theme developer since 2016 with 1,200+ community support replies and 5M+ cumulative plugin downloads
Verification standard: Codebase verification: Walkthrough of the exact production UI friction implementation in packages/tracker/src/index.ts (lines 220-301) and ClickHouse friction_spike anomaly thresholds.
Continue reading
Measure traffic, revenue, and UI friction in 1.96 KB gzipped
Cookie-less by default, powered by ClickHouse, and starting at $17/month for 100,000 monthly events with every feature unlocked.