Why is traditional single-pageview bounce rate misleading for blogs and documentation sites?
Traditional bounce rate marks every single-page visit as a bounce even if a developer spent four minutes reading your documentation, copied an API snippet, and solved their problem. TrimStats fixes this by pairing a Page Visibility API active-dwell timer in t.js with a ClickHouse bounce rule requiring both pageviews <= 1 and active duration under 10,000 ms.
- Legacy single-pageview bounce rules routinely report 75% to 88% bounce rates on successful technical docs and tutorials where readers get their answer on one page.
- TrimStats pauses engagement timing whenever document.visibilityState === "hidden" so forgotten background browser tabs never inflate average visit duration.
- Leave beacons flush on visibilitychange, pagehide, and SPA route transitions only when accumulated active time is at least 500 ms.
- Combining visibility-aware dwell (< 10 seconds) with opt-in 90% scroll reach distinguishes genuine content engagement from accidental clicks.
Why classic bounce rate punishes your best content
In legacy web analytics, a "bounce" meant one thing: a session containing a single pageview and zero subsequent page transitions. That definition made sense for multi-page 2008 news slideshows, yet it breaks completely on modern developer documentation, technical blog posts, and answer-first landing pages.
Consider what happens when an engineer searches Google for "Stripe webhook signature verification," lands on your documentation page, reads carefully for three minutes, copies your TypeScript snippet, and closes the tab. Under single-pageview bounce math, that successful visit registers as a 100% bounce with 0 seconds of time on page because no second pageview ever fired to compute a timestamp delta.
Legacy single-page bounce rate dramatically overstates exits on docs and guides
Illustrative bounce rate (%) comparing single-pageview-only rules vs TrimStats (<10s active dwell)
On high-intent docs and technical guides, single-pageview bounce formulas misclassify roughly half of engaged readers as bounces.
Methodology: Illustrative comparison demonstrating the structural gap between single-pageview-only bounce math and TrimStats active-dwell bounce math (pageviews <= 1 AND duration_ms < 10,000).
View chart data table
| Label | TrimStats (<10s active + <=1 pv) | Legacy (<=1 pv only) |
|---|---|---|
| Docs (/docs/*) | 31% | 82% |
| Pillar Guides | 34% | 79% |
| Comparison (/vs/*) | 39% | 64% |
| Pricing (/pricing) | 44% | 58% |
Worse still, naive Date.now() - pageLoadTime timers fail in the opposite direction. A visitor who opens three comparison tabs in the background, goes to lunch for 40 minutes, and closes Chrome inflates average session duration by an order of magnitude even though they spent four seconds looking at the screen.


How TrimStats measures true foreground engagement in 25 lines
TrimStats solves both distortions inside packages/tracker/src/index.ts using the browser Page Visibility API (document.visibilityState), pagehide, and SPA navigation hooks, all compiled inside the 1.96 KB gzipped bundle:
// Visibility-aware engagement timer in packages/tracker/src/index.ts
let visibleStart = document.visibilityState === 'hidden' ? 0 : Date.now();
let elapsedMs = 0;
const flushEngagement = () => {
if (visibleStart) {
elapsedMs += Date.now() - visibleStart;
visibleStart = document.visibilityState === 'hidden' ? 0 : Date.now();
}
if (elapsedMs >= 500) {
send({ t: 'leave', d: elapsedMs });
elapsedMs = 0;
}
};
document.addEventListener('visibilitychange', () => {
if (document.visibilityState === 'hidden') {
flushEngagement();
} else {
visibleStart = Date.now();
}
});
window.addEventListener('pagehide', flushEngagement);
Four deliberate engineering details make this tiny timer accurate in production:
- Pre-rendered and background-opened tabs start paused: If a user middle-clicks a link to open your post in a background tab,
document.visibilityStatestarts as'hidden', sovisibleStartinitializes to0. Counting begins only when the user actually focuses the tab. pagehideinstead of unreliableunload: Modern Chromium and Safari browsers preserve bfcache and frequently dropunloadhandlers, whereasvisibilitychange(to'hidden') paired withpagehideandnavigator.sendBeaconreliably delivers the finalleavebeacon even on mobile Safari tab switches.- 500 ms noise floor: Flushing only when
elapsedMs >= 500avoids cluttering ClickHouse with zero-duration redirect bounces or double-fired visibility transitions. - Automatic SPA route flushing: Whenever Next.js App Router, React Router, or Vue calls
history.pushState(or the user triggerspopstate),onRouteChange()flushes elapsed active time against the departing pathname before sending the incoming pageview beacon.
Why text/plain + navigator.sendBeacon prevents lost exit beacons
Exit timing fails in many analytics scripts not because the JavaScript clock is wrong, but because the browser cancels outbound network requests during tab teardown. A standard fetch() call with Content-Type: application/json triggers a cross-origin CORS preflight (OPTIONS) round trip that mobile Safari and Chrome frequently abort mid-flight when a user closes a tab or switches apps.
Inside packages/tracker/src/index.ts, TrimStats serializes the compact JSON payload into new Blob([body], { type: 'text/plain' }) and hands it directly to navigator.sendBeacon(endpoint, blob) (with a fetch(..., { method: 'POST', body, keepalive: true }) fallback when sendBeacon is unavailable). Using text/plain qualifies as a CORS simple request, removing the preflight round trip completely so the final leave beacon survives tab closure cleanly without adding latency to page navigation.
Average visibility-aware active dwell time reveals which pages hold reader focus
Seeded acme.dev 30-day demo workspace measuring foreground tab seconds per page
Excluding hidden background tabs exposes true foreground reading duration without 25-minute idle-tab outliers.
Methodology: Seeded acme.dev 30-day workspace demonstrating foreground active dwell aggregation (sum(active_duration_ms) / sessions).
View chart data table
| Label | Active dwell |
|---|---|
| /blog/script-benchmark | 3m 42s |
| /docs/quickstart | 2m 48s |
| /vs/google-analytics-4 | 2m 22s |
| /pricing | 1m 18s |
| / | 54s |
The ClickHouse bounce formula: pageviews <= 1 AND duration_ms < 10,000
On the analytics server, TrimStats computes bounce rate per session using both page depth and accumulated active foreground duration:
- A session is counted as a bounce if and only if
pageviews <= 1AND activeduration_ms < 10,000(10 seconds). - Average visit time is computed as
sum(active_duration_ms) / sessions, bounded per beacon (0to86,400,000 ms) and immune to background-tab inflation. - Sessions use a 30-minute sliding inactivity timeout refreshed automatically on every incoming event.
This 10-second active-focus boundary aligns cleanly with human reading behavior. Accidental clicks, mis-targeted search snippets, and slow-page abandonments leave within seconds and count as bounces; genuine readers who spend 90 seconds reading a guide or inspecting pricing count as engaged sessions.
How common visitor journeys compare across bounce formulas
Seeing concrete user journeys side by side clarifies why engineering and growth teams should stop optimizing for legacy single-pageview bounce rate:
| Visitor Scenario | Legacy Bounce (<= 1 pv) | Naive Load-to-Unload Timer | TrimStats Active Dwell (< 10s) |
|---|---|---|---|
| Reads API docs for 3m 20s, copies code, closes tab | Bounce (0s) | Engaged (3m 20s) | Engaged (3m 20s) |
| Opens blog in background tab for 25m, glances 4s, closes | Bounce (0s) | Engaged (25m 04s inflated) | Bounce (4s active) |
| Clicks paid ad, hits slow hero, hits Back in 3s | Bounce (0s) | Bounce (3s) | Bounce (3s active) |
Visits /pricing for 18s, navigates via SPA to /signup | Engaged | Engaged | Engaged (both routes timed) |
Passive requestAnimationFrame scroll reach without jank
When data-friction="true" is enabled, TrimStats attaches a single { passive: true } scroll listener gated by requestAnimationFrame. Instead of calculating layout geometry on every scroll pixel (which causes jank on long mobile guides), the callback checks (window.scrollY + window.innerHeight) / Math.max(document.documentElement.scrollHeight, 1) >= 0.9 at most once per animation frame. As soon as the visitor reaches 90% of document height, t.js sets scrolled90 = true, fires one { t: 'scroll', sc: 90 } beacon, and short-circuits every future scroll event until an SPA route transition calls trackPageview() and resets scrolled90 = false.


Auditing content performance with accurate engagement signals
Once noisy single-pageview bounces disappear from your dashboard, content and product teams can separate real problems from healthy behavior cleanly:
- High bounce (
> 65%under the 10-second rule) on a landing page: Indicates mismatched ad/SERP intent, slow LCP, or an unclear above-the-fold headline. - Low bounce (
< 35%) + high active dwell (> 2m) + low conversions: Signals readers value the article, yet your CTA placement or internal funnel links need tightening. - High active dwell (
> 2m) + low 90% scroll reach (< 20%): Points to an early wall of text, broken embedded table on mobile, or a confusing code snippet causing readers to stall above the midpoint. - Sudden bounce or conversion shift week over week: Triggers TrimStats' rolling 7-day
conversion_diporfriction_spikeanomaly detectors automatically without manual spreadsheet checks.
Verifying active dwell beacons locally in 30 seconds
You can verify visibility-aware timing on any site running t.js without reading server logs. Open Chrome DevTools, select the Network tab, enable Preserve log, and filter requests by /v1/collect. Load a page and read it for five seconds, then switch to another browser tab. A POST /v1/collect beacon fires immediately with t: "leave" and d close to 5000 milliseconds. Leave that tab hidden for two minutes, switch back for three seconds, and navigate to another route: the next leave beacon reports roughly 3000 milliseconds rather than 123000, confirming idle background time was excluded cleanly.
Read the full KPI formulas in Core Metrics & Sessions Docs or inspect how TrimStats pairs engagement with UI Friction Tracking.
Frequently asked questions
Why does TrimStats wait until 500 ms before sending a leave engagement beacon?
Do background browser tabs inflate average visit duration in TrimStats?
How does TrimStats measure active time across Next.js or React SPA route transitions?
How does TrimStats active bounce rate compare to GA4 Engaged Sessions?
Do leave engagement beacons count as extra billable events against my monthly quota?
Does active dwell tracking work in strict cookie-less mode without localStorage?
Sources & references
- MDN Web Docs: Page Visibility APIAccessed 2026-11-30
- TrimStats Core Metrics & Sessions DocumentationAccessed 2026-11-30
Co-founder and Product Manager at DotCamp LLC and co-creator of TrimStats. Publisher, SEO practitioner, and WordPress product leader building creator tools since 2012.
- • Co-founder & Product Manager at DotCamp LLC (est. 2019), guiding product strategy for Ultimate Blocks, WP Table Builder, OptimizeCamp, and TrimStats
- • Full-time publisher and digital marketer since 2012; founder of RoadToBlogging.com and WPLeaders.com
- • WordPress.org Plugin Developer, Support Contributor, and WordCamp Sylhet 2023 speaker on building WordPress products
Verification standard: Codebase verification: Direct walkthrough of the visibility-aware engagement timer in packages/tracker/src/index.ts (lines 125-167) and ClickHouse bounce calculation.
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.