How to Measure Real User Performance with Web Vitals
Collect field metrics from real visitors so you optimise what users experience, not what a lab test with a fast laptop shows.
On this page
Introduction
A lab performance test runs on a fast machine over a fast network and reports a number that no real user experiences. Users are on slow phones, congested networks and CPUs busy with other tabs, and their experience is what you actually need to improve. Field measurement collects metrics from real visitors, aggregating the times they saw and the interactions they had. Web Vitals are a small set of such metrics, chosen because they correlate with what users perceive. This article covers what to measure, how to collect it without slowing the page, and how to read the distribution rather than the average.
Why Field Data Beats Lab Data
A lab test is reproducible and useful for catching regressions before release, but it runs in a controlled environment that is not the user’s. The same page can be fast on a developer’s machine and slow on a mid-range Android phone over a mobile network. Field data captures the real distribution: the fast cases, the slow tail, and the device and network mix.
The two are complementary. Lab data tells you what a change did under fixed conditions; field data tells you whether it mattered to users. Use lab data to gate changes and field data to decide what to work on, because the biggest field problem is often not the one the lab measures.
What to Measure
Core Web Vitals are the small set that correlates with user perception: Largest Contentful Paint for loading, Interaction to Next Paint for responsiveness, and Cumulative Layout Shift for visual stability. Each maps to a user experience: the main content loaded, the interface responded, and the page did not jump. Collect these three plus the underlying timing entries that help diagnose them.
Metric names change as the web evolves, so collect the currently recommended set and keep the raw timing data, because a new metric can often be computed from data you already collected. In particular, capture the navigation timing and the largest contentful paint entry so you can recompute several metrics later.
// Collect Core Web Vitals with the web-vitals library and send to your endpoint.
import { onLCP, onINP, onCLS } from 'web-vitals';
function send(metric) {
const body = JSON.stringify({
name: metric.name,
value: metric.value,
rating: metric.rating, // 'good' | 'needs-improvement' | 'poor'
id: metric.id,
navigationType: metric.navigationType,
});
// sendBeacon survives page unload; keep the payload small and beacons cheap.
navigator.sendBeacon('/rum', body);
}
onLCP(send);
onINP(send);
onCLS(send);
Collecting Without Slowing the Page
Measurement must not cost the performance it measures. Load the collector asynchronously and late, keep the payload tiny, and send it with the beacon API so it does not block unload. Sampling is often acceptable: measure every visitor, a fraction, or a fraction with more detail, depending on the volume. A full-fidelity sample of a fraction is usually better than a coarse measurement of everyone.
Attribute each metric with what explains it: the device class, the connection type, the page route and the release. Without the route you cannot tell which page is slow, and without the release you cannot correlate a regression with a deploy. Keep the attributes low-cardinality so the data stays queryable, and avoid anything that identifies a user.
Reading the Distribution
The average hides the tail, and the tail is what users complain about. Report the 75th percentile, which is the threshold the Core Web Vitals guidance uses, and look at the distribution to see how many visitors are in the poor range. A p75 that is good can still hide a long tail of very slow experiences on a subset of devices.
Segment the distribution by device class and connection, because a metric that is good on desktop and poor on mobile is a different problem from one that is uniformly mediocre. Segment by route, because the homepage and the checkout page have different performance needs. The actionable insight is usually in a segment, not in the overall number.
-- p75 LCP per route and device class, plus the share in the "poor" range.
SELECT route,
device_class,
percentile_cont(0.75) WITHIN GROUP (ORDER BY lcp_ms) AS p75_lcp_ms,
count(*) FILTER (WHERE lcp_ms > 4000) * 100.0 / count(*) AS pct_poor
FROM rum_lcp
WHERE collected_at > now() - interval '7 days'
GROUP BY route, device_class
ORDER BY p75_lcp_ms DESC;
-- Compare the current release against the previous one for the same route:
SELECT release,
percentile_cont(0.75) WITHIN GROUP (ORDER BY inp_ms) AS p75_inp_ms
FROM rum_inp
WHERE route = '/checkout'
GROUP BY release
ORDER BY release;
From Measurement to Fix
Field data tells you which page and which metric; the next step is to find the cause. Correlate the slow metric with the resources the page loads, the size of the largest element, and the third-party scripts, and use the lab tools to reproduce the expensive path. A layout shift often comes from an image without dimensions or a font that swaps; a slow LCP often comes from a large hero image or a render-blocking resource.
Add a budget so a regression is caught: a target for the p75 of each Core Web Vital, checked in the pipeline or monitored with an alert. Without a budget, performance drifts as features are added, and the field data only tells you after users have felt it. The budget turns field data into a gate.
Privacy and Consent
Performance data should not identify a user. Do not send user ids, full URLs with identifiers, or anything that could single out an individual. Aggregate at the endpoint, keep only low-cardinality attributes, and respect the user’s consent and the applicable privacy rules; in many jurisdictions performance measurement is permissible without consent only if it is strictly necessary and does not track the user.
Store the data in a form that supports the analysis you need but not re-identification: route templates rather than full paths, device classes rather than device models, and timestamps rounded. The goal is to know that the checkout page is slow on mid-range Android, not which user saw it slow.
Conclusion
Measure performance from real users, not only from a lab, because the user’s device and network are the conditions that matter. Collect the Core Web Vitals, send them with a beacon so the measurement does not slow the page, attribute them with route and device, and read the p75 and the distribution rather than the average. Segment to find the actionable case, correlate it with the resources to find the cause, and set a budget so a regression is caught. Then optimise what users actually experience.
Sources: web.dev: Core Web Vitals, web-vitals library, W3C: Largest Contentful Paint.
FAQ
- Why is field data preferred over a lab test?
- A lab test runs in a controlled environment, not on the user device and network. Field data captures the real distribution, including the slow tail and the device mix, which is what you need to decide what to optimise. Lab data still gates changes before release.
- Why report the 75th percentile?
- The average hides the tail that users complain about. The 75th percentile is the threshold the Core Web Vitals guidance uses and it reflects a large share of visitors; segment it by device and route to find the actionable case rather than a single overall number.
Report a problem with this articleOpens a pre-filled issue on GitHub.