engineering7 min read

Rage Click & Dead Click Tracking Without Replay

Inside the exact Euclidean rage-click clustering, 500 ms structural MutationObserver dead-click check, and CSS selector hints built into TrimStats 1.96 KB t.js.

Imtiaz Rayhan
Imtiaz RayhanCo-Founder & Lead Engineer, DotCamp & TrimStats
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.(packages/tracker/src/index.ts)
Executive finding

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.

Key takeaways
  • 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:

  1. 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.
  2. Privacy masking liability: One unmasked input field, billing modal, or customer table leaks sensitive PII into third-party video recordings, forcing constant CSS data-mask maintenance 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.

Seeded demo workspace
TrimStats UI Friction report highlighting 184 rage clicks, 342 dead clicks, 36.5% 90% scroll reach, and top friction pages led by /pricing and /docs/installationTrimStats UI Friction report highlighting 184 rage clicks, 342 dead clicks, 36.5% 90% scroll reach, and top friction pages led by /pricing and /docs/installation
Ranking pages by affected-visitor friction rate puts broken pricing and checkout interactions immediately at the top of the engineering queue.

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

ms
rAF scroll throttle frame (60 Hz)(passive listener, fires once at 90%)
~16 ms
Dead-click MutationObserver cap(disconnects immediately on mutation)
500 ms
Rage-click 3-click cluster window(within 30 px Euclidean radius)
1,000 ms
Active dwell threshold (bounce floor)(visibility-aware tab focus)
10,000 ms

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.

Source: TrimStats tracker source (packages/tracker/src/index.ts)
View chart data table
LabelWindow duration
rAF scroll throttle frame (60 Hz)~16 ms
Dead-click MutationObserver cap500 ms
Rage-click 3-click cluster window1,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.

Seeded demo workspace
TrimStats Top Friction Elements view pinpointing broken CSS selectors button#annual-toggle and span.plan-quota-badge with affected user countsTrimStats Top Friction Elements view pinpointing broken CSS selectors button#annual-toggle and span.plan-quota-badge with affected user counts
Instead of scrubbing dozens of session-replay videos, engineers see the exact CSS selector hint, signal type, and number of affected visitors in one table.

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

%
/pricing(134 of 2,094 visitors)
6.4%
/checkout(68 of 1,388 visitors)
4.9%
/signup(51 of 1,840 visitors)
2.8%
/features/revenue-attribution(36 of 1,920 visitors)
1.9%
/docs/quickstart(23 of 1,280 visitors)
1.8%

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.

Source: TrimStats seeded demo workspace (acme.dev)
View chart data table
LabelFriction rate
/pricing6.4%
/checkout4.9%
/signup2.8%
/features/revenue-attribution1.9%
/docs/quickstart1.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 on button#apply-coupon.btn-ghost or button.checkout-submit.
  • Deceptive static pills (dead_click): Marketing badges styled like interactive switches (such as div.annual-savings-pill next 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?
Native interactive elements (a, button, input, select, textarea, label, and [role="button"]) frequently trigger async network requests, file downloads, or clipboard copies that do not mutate the DOM within 500 ms. Broken buttons are caught cleanly by rage clicks instead, preventing false dead-click noise.
Does enabling data-friction="true" slow down scrolling or click responsiveness?
No. Both the click and scroll listeners register with { passive: true }, scroll depth checks run inside requestAnimationFrame and stop firing permanently once 90% depth is reached on a route, and the dead-click MutationObserver disconnects on the first DOM change or after 500 ms.
Can CSS selector hints leak customer PII?
No. TrimStats constructs hints solely from tag name, element id, and up to two class names (capped at 120 characters) and never reads textContent, innerText, form values, or ARIA labels containing user data.
When should a product team still use video session replay instead of lightweight friction selectors?
Use full video session replay (such as PostHog or FullStory) when debugging complex canvas editors, drag-and-drop workflows, or visual layout regressions where mouse paths matter. Use TrimStats lightweight friction selectors when you want zero replay bloat, zero PII masking risk, and fast identification of broken buttons or dead pills.
Does UI friction tracking work on Next.js, React, and Astro single-page apps?
Yes. TrimStats hooks history.pushState and popstate automatically, resets the 90% scroll reach flag on every client-side route transition, and tags every rage_click or dead_click beacon with the active SPA pathname.
Can TrimStats alert engineering automatically when a deploy introduces a rage-click spike?
Yes. TrimStats evaluates friction_spike anomalies every 6 hours across rolling 7-day UTC windows. When a route records at least 15 friction clicks and rises 50% or more over the prior 7-day baseline, it raises a dashboard insight and optional deduplicated email alert.

Sources & references

Imtiaz Rayhan
Written & verified by
Imtiaz Rayhan (Co-Founder & Lead Engineer, DotCamp & TrimStats)

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.

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.