Web vitals and JavaScript errors
Open Settings → General → Tracking add-ons and tick Web vitals and JS errors. Your main tracking tag then loads the vitals script by itself within a minute, using the tag's site ID. If you serve the tracker through a first-party proxy, forward all of /js/*, not only /js/script.js, so the tracker can load its add-ons from the same place.
Or add the script by hand beside your main analytics tag. Replace SITE_ID with your website ID and use the tracking origin shown in Settings → General. A hand-installed copy and the one the tracker loads never both run.
<script defer src="https://t.analyticfast.com/js/vitals.js" data-website-id="SITE_ID"></script>
The dashboard's Web vitals and JavaScript errors cards populate after a real browser visit ends or the tab first becomes hidden. The script makes at most one accepted request per document lifecycle. SPA navigation does not reset measurements; the document's initial path is used. Back/forward cache restoration does not send a second beacon. No cookies or visitor IDs are used. Vitals do not count toward plan event quotas.
Sampling and opt-outs
Vitals sample 25% of page loads by default. Add data-vitals-sample="0.1" to your tracking tag for 10%, or data-vitals-sample="1" for all pages (on a hand-installed vitals tag, use data-sample). Supported rates are 0.01–1. Errors are collected independently of vitals sampling, up to five per page.
The script honours localStorage.ml_ignore === "1", data-disabled (on its own tag or the tracking tag), webdriver and the main tracker's localhost exclusion. For local testing add data-allow-localhost and make sure the site's hostname allowlist permits that host. data-disabled and local opt-out are checked again before sending. If consent is required, load this script only after consent, or keep it disabled. It never reads analytics cookies or sends visitor identity.
Messages have email-like strings redacted and are truncated to 200 characters. Source URLs have credentials, query strings and fragments removed. Only the source URL and line/column are recorded; no stacks, rejection objects, DOM targets, query strings or hashes are sent. Avoid personal data in page paths, file paths and error messages: arbitrary sensitive text cannot be reliably recognised automatically.
Measurements and thresholds
PerformanceObserver support varies by browser. Unsupported metrics remain missing rather than becoming zero; a supported layout-shift observer starts CLS at zero. Event Timing observes interaction entries at the 16 ms minimum duration threshold. INP is an approximation using the worst observed interaction duration, without the full web-vitals outlier algorithm. Pages without an observed interaction have no INP sample. CLS uses the largest session-window total: gaps shorter than one second, total window shorter than five seconds, excluding shifts following recent user input.
| Metric | Good | Needs improvement | Poor | Finite bucket precision |
|---|---|---|---|---|
| LCP | ≤ 2,500 ms | ≤ 4,000 ms | > 4,000 ms | 500 ms |
| INP (approximate) | ≤ 200 ms | ≤ 500 ms | > 500 ms | 50 ms |
| CLS | ≤ 0.1 | ≤ 0.25 | > 0.25 | 0.025 |
| FCP | ≤ 1,800 ms | ≤ 3,000 ms | > 3,000 ms | 300 ms |
| TTFB | ≤ 800 ms | ≤ 1,800 ms | > 1,800 ms | 200 ms |
LCP, INP and CLS are Core Web Vitals. FCP and TTFB are supporting diagnostics. These are field measurements; they do not imply a Google ranking assessment.
Each metric has a fixed histogram: an exact zero bucket, 16 intervals of the width above, and an overflow bucket. p75 uses nearest rank (ceil(samples × 0.75)) over merged bucket counts, independently per metric. We report the containing interval's upper bound; the overestimate is less than one bucket width. Overflow (> 8,000 ms LCP, > 800 ms INP, > 0.4 CLS, > 4,800 ms FCP, > 3,200 ms TTFB) is a lower bound with no finite precision guarantee. The API includes lower, upper (null for overflow), metric sample counts and rating. Percentiles merge histograms; they never average daily p75 values. Page rankings use the selected metric's estimated p75, worst first.
Rollups use complete UTC dates, even when the analytics dashboard uses another timezone or an hourly range. Responses show the actual UTC date bounds and are limited to 90 days ending at the requested end date. Session filters do not apply because there is no session identity. Device classification uses the request User-Agent.
Storage and limits
One sampled page writes one web_vitals_daily row, with fixed histogram counters, plus index writes. Duplicate errors within a beacon are combined: each distinct fingerprint writes one js_errors_daily row. The fingerprint hashes the redacted message, clean source and line; column does not split a group. Counters update in one atomic D1 batch, at most six statements. There is no raw event table, per-beacon event quota write, or extra D1 rate-limit counter. Hosted collection uses the same INGEST_LIMITER sender bucket as normal analytics; self-hosted installs without that optional binding have no vitals rate limiting.
Per site and UTC day we keep 200 distinct page paths, then fold new vitals paths into (other) (at most 603 path/device rows). Existing paths keep updating. We keep at most 100 distinct error fingerprints; subsequent new groups are dropped while existing groups keep updating. Each error row retains at most 20 distinct example page paths; lists display 20+ when capped. Aggregate reports return at most 50 pages or error groups. These caps bound cardinality, not the total number of beacons.
The public write-only endpoint accepts at most 4 KB and drops bots, unknown sites, foreign hosts/origins and rate-limited senders quietly. Public site IDs and hostname checks reduce pollution; they do not authenticate a server-side sender. Data expires after 90 UTC days through pruneVitals(db, now). Maintenance must be wired by the deployment lead into the existing scheduled job; no new cron expression is needed. Deleting a site cascades to both tables.
Read API and MCP
Authenticated dashboard reads: GET /api/sites/:siteId/web-vitals?period=30d&metric=lcp and GET /api/sites/:siteId/js-errors?period=30d. The usual custom from/to parameters apply. Both enforce tenant access and dashboard plan entitlement. MCP tools web_vitals and js_errors require analytics:read; workspace and site-bound token restrictions apply. They accept site_id, period, from and to; web_vitals also accepts metric.
Sources: Core Web Vitals, CLS windows, INP, FCP, TTFB, PerformanceObserver, Event Timing, D1 batches, D1 limits, Workers rate limiting.