Frontend Observability: RUM and Core Web Vitals Monitoring
However healthy your server metrics are, they cannot answer what the user actually experienced in the browser. A page load passes through DNS, connection, TLS, request, transfer, parse, render, script execution, layout, and paint; when any one of those slows down, the user sees one of three things: a blank screen, a frozen page, or content that suddenly jumps. None of that leaves a mark on a server-side error-rate curve.
Turning experience into quantifiable data needs an entirely different set of observation points: ones that run inside the user's browser and measure with the user's device, the user's network, and the user's actual page. That is real user monitoring, or RUM.
The most common misuse of RUM is treating it as another Lighthouse. The two appear to measure the same thing and in fact measure two different worlds: one measurement under controlled conditions, versus the actual distribution of thousands of real users. That difference is the starting point for everything else. This article covers the lab-versus-field distinction, why the three core metrics are defined as they are, why p75 matters, collection and reporting, the SPA problem, cost versus sampling, and finally attribution and common misuse. For the external view from the synthetic side, see Synthetic Monitoring in Practice.
1. Lab and Field: Two Fundamentally Different Kinds of Data
1.1 Lab data: a single measurement under controlled conditions
Lab data is one measurement taken on a fixed device, a fixed network, and a fixed page state. Lighthouse is the archetype: it loads the page on a controllable machine, throttles network and CPU, applies a fixed rule set, and produces a score plus a diagnostic list.
The value of lab data is reproducibility. The same commit with the same configuration produces roughly the same result twice, so it works as a regression check: did this change make some metric worse? It also yields definite diagnoses — "this image is not compressed", "this script blocks rendering" — conclusions that do not depend on a sample.
Its limitation is equally definite: it does not know who your users are. Device model, bandwidth, and CPU speed are assumptions in the configuration, while the real distribution may be nothing like it — a large fleet of low-end Android phones, slow mobile networks, older browsers, battery-saver mode. A lab report saying "first paint in 1.2 seconds" and "half your users take more than 4 seconds" can both be true.
1.2 Field data: the actual distribution of real users
Field data comes from every real visit: the browser collects metrics, attaches device and network context, reports them to a server, and the server aggregates a distribution. RUM is one implementation of field data; Google's CrUX report is another common source.
The value of field data is that it represents the real distribution. It inherently includes the long tail — the users with the oldest devices, the worst networks, the heaviest pages — who are exactly the ones lab testing never sees and exactly the ones most likely to leave. It also reveals differences lab cannot: a region that is uniformly slow, a browser version that is uniformly bad, a component on one landing page that drags the whole page's LCP down.
The price of field data is that it does not tell you why. The distribution tells you a group of users exceeds 4 seconds LCP; why, which element, which resource, which phase, needs additional instrumentation. That division of labour is the next section's subject.
1.3 On conflict, field wins and lab explains
When the two disagree, the order of judgement is fixed: field wins, and lab explains why. The reason is simple — field is what users actually got, lab is a simulation under assumptions, and users do not browse according to your assumptions.
The practical loop has three steps. First, spot the anomaly in field data: a page's p75 crosses the threshold, one device type is clearly worse than the others, p75 moves up after a release. Second, reproduce and localise with lab: run Lighthouse on the same page and read the specific findings — uncompressed images, render-blocking scripts, images without dimensions, oversized main-thread tasks. Third, verify in field after the fix: did p75 actually fall, or did the lab score merely go from 92 to 96?
The third step is where most teams slip. Verifying only in lab produces "score up, users unchanged"; chasing lab scores without watching the field distribution spends effort on pleasing a tool rather than speeding up users. A lab score is a diagnostic instrument, not an acceptance criterion. For how experience feeds into search performance, see Website Speed and SEO Impact.
2. What Each of the Three Metrics Measures
2.1 LCP: loading performance, meaning "when the main content became visible"
Largest Contentful Paint records the moment the largest content element in the viewport finishes painting. It chooses "largest element" over "page load complete" because the latter means nothing to a user: a page may present its content in 500 milliseconds or finish loading after 5 seconds, and the feeling of "it opened" corresponds to the former.
The element LCP refers to changes as the page evolves: a block of text, an image, a video poster can each become the largest element in turn, and LCP takes the last occurrence. That means lazy loading, carousels, and skeleton-to-content swaps all affect the value — a large image that appears late becomes the LCP element and inflates the number even if the page "looked ready" much earlier.
LCP breaks into four phases: time to first byte, resource load delay, resource load duration, and element render delay. The breakdown is useful because each phase has entirely different remedies — slow server, late resource discovery, oversized resource, blocked main thread: four directions, four fixes. Looking only at the total never tells you which one applies.
2.2 INP: responsiveness, meaning "how long until feedback after a tap"
Interaction to Next Paint records the delay from each interaction — click, tap, key press — to the next paint, and reports one representative value for the visit, usually the worse one. It replaced First Input Delay, which measured only the input delay of the first interaction, that is, the time from the user's action until the event callback begins executing, with no coverage of callback execution or the subsequent paint — and the lag users actually feel usually lives in those two segments.
The replacement changed the optimisation direction. Under FID, a handler that started early scored well even if it then ran three hundred milliseconds of synchronous work. Under INP, handler execution and the resulting repaint cost are both counted, which makes long tasks, large DOM updates, and synchronous layout the primary targets.
One implication is easy to miss: INP is an interaction metric, so it only means something on interactive pages. A purely static content page has no interactions and therefore no INP; judge such pages on LCP and CLS instead of manufacturing interactions to complete a set of three.
2.3 CLS: visual stability, meaning "did anything jump"
Cumulative Layout Shift accumulates unexpected layout shift. It multiplies two factors: the impact fraction (how much of the viewport moved) and the distance fraction (how far elements moved). Movement the user initiated, such as expanding an accordion by clicking it, is excluded.
CLS deserves its own metric because its damage differs from slowness: content that moves the instant a user is about to tap causes mis-taps, wrong form entries, and paragraphs that vanish mid-read. None of that shows up in a speed metric — the page may load quickly and still jump every two seconds.
The three most common causes all trace to unknown dimensions: images without width and height, ad slots injected late, and line-height changes when a font swaps. The shared remedy is reserving space — aspect ratios for images and embeds, preallocated containers for dynamically inserted content, and a sensible font-display strategy.
3. Why You Must Look at p75
3.1 The official criterion is already "75% of visits pass"
Core Web Vitals is judged at the 75th percentile, not on averages and not on medians: a page (or origin) passes when its LCP, INP, and CLS at p75 meet the "good" thresholds — LCP at or under 2.5 seconds, INP at or under 200 milliseconds, CLS at or under 0.1.
That choice of criterion is itself a value judgement: it accepts that a quarter of visits may fall short, and draws the line there. That means two things. Passing at p75 does not mean every user is fast. And a healthy-looking average with a failing p75 is both common and serious.
Mobile and desktop must be reported separately. Device capability, network conditions, and page composition differ enormously, so a combined p75 represents neither. The official assessment separates them too, and your dashboard has no reason to merge them.
3.2 Averages hide the long tail
Averages almost always mislead here, because of the shape of the distribution. Frontend performance is classically long-tailed: most visits cluster in a fast band, and a minority are extremely slow — low-end devices, weak networks, cold caches, third-party script timeouts. The average is dragged down by the many fast samples and looks acceptable while the tail lives an entirely different experience.
A concrete shape: ninety percent of visits load with LCP around 1.5 seconds and ten percent take 8 seconds. The average is about 2.15 seconds, close to the "good" threshold. Where does p75 land? Near 1.5 seconds — which is exactly the point: both the average and the headline percentile can be constructed to be reassuring. What actually matters is the distribution itself: how many slow users there are in absolute terms, and which device, region, and page they cluster in.
So report three things together: p75 to align with the official criterion, p95 or p99 to size the tail, and a histogram to see the shape — bimodal or unimodal. Only together do they tell you whether slowness is a small anomaly or a general decline.
3.3 Percentiles cannot be averaged across dimensions
One technical detail directly determines whether your reports are trustworthy: percentiles are not additive. Averaging the p75 of ten pages produces a meaningless number; the correct method is to merge all samples and recompute.
The same holds for averaging p75 across devices or across hours — the result describes neither A nor B. That is why RUM data models usually keep raw samples or histogram buckets rather than a single precomputed percentile: the latter loses the ability to recompute at aggregation time, and that ability cannot be recovered later.
Confirm this at selection time: can the platform recompute percentiles over arbitrary dimensions? If not, your reporting is limited to the platform's preset cuts, and any new business question requires starting over.
4. Collection and Reporting
4.1 Observing entries with PerformanceObserver
The browser exposes a standard performance entry interface, and RUM collection is built on it. PerformanceObserver subscribes to entry types: largest-contentful-paint yields the LCP candidate element and time, layout-shift yields the impact fraction and distance of each shift, and event yields interaction timestamps and processing duration (combined with durationThreshold you can collect only slow interactions and keep volume down).
The minimal integration below uses the web-vitals library, which wraps those observers:
import { onLCP, onINP, onCLS } from 'web-vitals';
function report(metric) {
const payload = {
name: metric.name,
value: metric.value,
rating: metric.rating, // good / needs-improvement / poor
id: metric.id,
path: location.pathname,
conn: navigator.connection && navigator.connection.effectiveType,
};
navigator.sendBeacon('/api/rum', JSON.stringify(payload));
}
onLCP(report);
onINP(report);
onCLS(report);
Three details matter. First, always report id: within one visit LCP is updated several times and only the last value is final, so the server needs id to deduplicate, otherwise intermediate values are recorded as samples. Second, rating is computed by the library against the thresholds, so the server can count on it directly instead of reimplementing threshold logic. Third, context such as path and connection type must travel with the value, or you receive numbers you cannot slice.
4.2 Reporting timing: use visibilitychange, never unload
When to send the data is an easy decision to get wrong. The common mistake is binding to unload or beforeunload — events that are increasingly unreliable in modern browsers, especially on mobile: a user may switch away, kill the tab, or have the page frozen for power saving, and in those cases unload never fires.
The reliable approach is to listen for visibilitychange and report when the page becomes hidden. That event fires in every mainstream browser and covers the main ways of leaving — switching tabs, going to the background, closing. Combined with sendBeacon, which lets the browser complete the send in the background without blocking unload, you get a path that does not lose data.
One more detail: LCP and CLS keep updating while the page lives, so do not report exactly once. Report the current cumulative values on each visibilitychange; a single visit may report several times, and the server takes the last or the maximum per id. That way data is not stranded when a user never leaves the page.
4.3 The SPA problem: soft navigation does not load a page
In a single-page application, a route change does not trigger a page load, so the boundaries of "page", "LCP", and "CLS" all need redefining. Without handling, two classic errors appear: the whole session has one LCP, taken from the initial load, and layout shifts from later route changes accumulate into the same CLS, inflating it indefinitely.
The fix is to reset context on route change: give each route an independent view identifier, attribute metrics from that route to that view, compute CLS within each view, and restart LCP for each view. Report the route path as a dimension, or you end up with "the app is slow", which is not actionable.
Soft navigation carries a second difficulty: after a route change, new content may render within a few hundred milliseconds or may wait for a data request. Those two cases look entirely different in the metrics, so attribution must separate "route changed" from "data ready" — otherwise a slow API is misdiagnosed as slow rendering.
5. Collection Cost, Sampling, and Privacy
5.1 Collection must not become the performance problem
The first rule of RUM: observation must not disturb the observed. A tens-of-kilobytes SDK loaded synchronously on the critical path directly inflates the LCP it is measuring; a reporting routine that serialises synchronously inside an interaction callback directly inflates the INP it is measuring.
Three practical constraints. First, load the SDK asynchronously in its own chunk so it does not block first paint, and defer initialisation until the page is interactive. Second, report with sendBeacon to avoid occupying the main thread and connections; batch and cap request size instead of firing many small requests. Third, keep the collection logic light — no heavy serialisation or large recomputation on every interaction; do the assembly in idle time.
Testing whether you have tripped over this is direct: compare field data before and after integration. If p75 worsens once RUM is in place, the observation cost is being paid by users, and the thing to fix first is collection, not the page.
5.2 Sampling rate and percentile stability trade off against each other
High-traffic sites usually report a proportion of visits rather than all of them. Sampling has a side effect that must be understood: it directly affects percentile stability.
p75 needs enough samples to be stable. With only a few dozen visits a day, p75 is essentially noise; discount it by a sampling rate and the sample count falls further, so the percentile swings widely and any threshold alert flickers on pure noise. That is not a threshold problem; it is a sample-size problem.
The practical approach is to treat use cases separately: sample performance metrics proportionally while guaranteeing every important slice — page, device, region — has enough samples per day; keep error and crash events at full rate, because they are rare and individually valuable; reduce or remove discounting on critical landing pages and apply more on long-tail pages.
Accept one further fact: the optimum between sampling rate and precision is not a constant. It moves with traffic, page count, and slice granularity. Make it configurable, and after launch validate it once by comparing full-rate data against sampled data for the same period, rather than picking a percentage by feel and never revisiting it.
6. Attribution and Common Misuse
6.1 From "LCP is slow" to "this element's resource is slow"
Saying "this page has p75 LCP of 4.2 seconds" is useless because it drives no fix. An actionable conclusion answers four layers: which element is the LCP element, what its resource is, which phase of loading was slow, and whether the slowness is in the server, the network, or the main thread.
The four layers map to four remedies. If the element is an image and the resource is large, compress and convert formats — see the Image Optimisation and CDN Guide. If discovery is late, check whether it is referenced indirectly through CSS or script and whether it should be preloaded. If time to first byte is high, inspect the server and CDN cache hit rate. If render delay is long, look for long tasks blocking the main thread.
INP attribution follows the same principle with different layers: which interaction was slow, how long the handler took, whether it forced synchronous layout, and whether long tasks queued ahead of it. CLS attribution asks which element moved, what was above and below it, and why unpredicted content was inserted. The three attribution chains differ, so putting them on one shared dashboard is a common mistake — each needs its own drill-down dimensions.
Connecting RUM data to tracing is the last step: the backend request behind a slow interaction, the CDN cache status behind a slow load, both require cross-source correlation. The method is in APM and Distributed Tracing.
6.2 Four common misuses
First, treating a Lighthouse score as an SLA. The score is a synthetic 0-to-100 number whose movement is not linear with real user experience; putting it in a contract or an external promise means promising a field outcome with a lab number.
Second, looking only at averages. The reason was covered above, but one variant deserves its own mention: teams watching "average LCP" often see a flat line while complaints rise, because a growing share of slow users is diluted by fast ones.
Third, not separating device and region. Low-end and high-end phones, weak and fibre networks have entirely different distributions, and merging them averages away the users who most need optimisation. Mobile-first sites especially should benchmark against the mobile p75.
Fourth, using RUM as a real-time alert source. RUM's value is analysis and trend; its data is sampled, delayed, and lossy, so using it as a "has this line been crossed in the last minute" source makes alerting itself unstable. Alerts belong on stable metrics such as entry-layer error rate and server latency, while RUM is for post-hoc attribution and optimisation validation. Tiering and inhibition are covered in the Monitoring and Alerting Guide.
7. Rollout Order and a Self-Check
7.1 From zero to actionable RUM
Step one: collect three metrics and no dimensions at all. The goal is to prove the chain from browser collection through reporting and storage to a p75 chart, and to confirm the reporting timing is right — visibilitychange, not unload. That can be done in a day, and it decides whether everything afterwards is trustworthy.
Step two: add dimensions — page path, device type, connection type, region, browser version. Dimensions are where RUM's value lives: a p75 without dimensions is just a number, while a p75 with dimensions answers who is slow. Add error collection at the same time, sharing the same context, which saves a lot of investigation time.
Step three: build attribution capability — record the LCP element and its resource per core page, record handler duration for slow interactions, record which element moved for CLS. Once these exist, RUM turns from a dashboard into a diagnostic tool.
Step four: close the optimisation loop. Fold p75 and p95 into release checks, compare field data after each change rather than only looking at the lab score, and queue persistently degrading pages for optimisation. Specific techniques are in Core Web Vitals Optimisation, and measuring the link to search performance is covered in SEO Performance Tracking.
7.2 A self-check table
| Check | Criterion | What to do if it fails |
|---|---|---|
| Field data used for judgement | A p75 from real user data exists | Integrate RUM before trusting lab |
| p75 rather than mean | Primary reporting uses p75 | Change the metric and recompute history |
| Devices and regions split | Mobile and desktop reported separately | Re-aggregate with dimensions |
| Reliable reporting timing | visibilitychange plus sendBeacon |
Replace the unload approach |
| SPA measured per route | Each view computes and reports separately | Add route reset logic |
| Sampling validated | Precision compared against full rate | Run one comparison before fixing the rate |
| Element-level attribution | Can name the element and phase | Collect LCP element and resource data |
| Clear split from alerting | Alerts on stable metrics, RUM for analysis | Change the alert source |
RUM maturity is not measured in how many metrics you collect but in one capability: when someone asks "why does the site feel slow", can you answer in one screen with the page, the device class, the element, and the phase? If yes, three metrics suffice; if no, more metrics only stack the numbers higher.
Source: Datadog documentation (Real User Monitoring) and the Core Web Vitals metric definitions from Google web.dev. Compiled and interpreted by 16IDC.
Integration & Code Examples
Example 1: A web-vitals reporting script with sampling and sendBeacon
// rum.js
import { onCLS, onINP, onLCP } from 'web-vitals';
const ENDPOINT = import.meta.env.VITE_RUM_ENDPOINT;
const SAMPLE_RATE = 0.1;
function send(metric) {
const body = JSON.stringify({
name: metric.name,
value: Math.round(metric.value),
rating: metric.rating,
id: metric.id,
path: location.pathname,
});
if (document.visibilityState === 'hidden' && navigator.sendBeacon) {
navigator.sendBeacon(ENDPOINT, new Blob([body], { type: 'application/json' }));
return;
}
fetch(ENDPOINT, {
method: 'POST',
body,
keepalive: true,
headers: { 'Content-Type': 'application/json' },
}).catch(() => {});
}
if (Math.random() < SAMPLE_RATE) {
onCLS(send);
onINP(send);
onLCP(send);
}
The endpoint comes from an environment variable and the sample rate caps collection cost; prefer sendBeacon when the page is hidden and fall back to keepalive so the final request survives unload.
Example 2: Attribute LCP to a specific element and resource
new PerformanceObserver((list) => {
const entries = list.getEntries();
const last = entries[entries.length - 1];
if (!last) return;
console.info({
startTime: Math.round(last.startTime),
element: last.element?.tagName,
url: last.url || '(inline)',
size: last.size,
});
}).observe({ type: 'largest-contentful-paint', buffered: true });
new PerformanceObserver((list) => {
for (const e of list.getEntries()) {
if (e.duration > 500) console.info('slow resource', e.name, Math.round(e.duration));
}
}).observe({ type: 'resource', buffered: true });
A single score cannot locate a problem; logging the element, the resource URL and the duration together tells you which image to compress and which script to split - the most concrete layer of the "which page, which element, which phase" question.
Limitations
- However healthy your server metrics are, they cannot answer what the user actually experienced in the browser.
- It also yields definite diagnoses — "this image is not compressed", "this script blocks rendering" — conclusions that do not depend on a sample.
- Its limitation is equally definite: it does not know who your users are.
- The price of field data is that it does not tell you why.
- The reason is simple — field is what users actually got, lab is a simulation under assumptions, and users do not browse according to your assumptions.
FAQ
What prerequisites must be in place before RUM ships?
Three things: samples, dimensions and no slowdown. Load the SDK asynchronously so it never blocks first paint, send through sendBeacon on visibilitychange rather than unload, and start with just LCP, INP and CLS to prove the pipeline; then confirm the backend stores raw samples or histogram buckets rather than a pre-aggregated p75.
How do you measure a safe sampling rate?
From the sample count each slice needs, not a fixed percentage. A page with a few dozen daily visits already reads p75 out of noise, and sampling shrinks that into jumpy percentiles; keep error events at full volume, sample core landing pages lightly, allow heavier sampling on long-tail pages, then validate against a full-volume window.
Why is LCP p75 above 2.5 seconds?
Check p75 first, then unwind four layers. Find which page and device crosses the threshold, identify the LCP element and its resource, split resource load delay from a slow first byte, and look for long tasks on the main thread. Reporting that p75 is 4.2 seconds drives no fix on its own.
Should alerts come from server metrics instead of RUM?
Yes — alerts from stable metrics, RUM for analysis. Sampled, delayed and occasionally dropped data makes a noisy trigger for whether the line was crossed this minute, while entry error rate and server latency hold steadier; RUM then attributes the regression and confirms whether p75 actually fell.
Related Providers
- Datadog: join RUM p75 with backend traces and check browser SDK sampling plus billing units.
- SpeedCurve: put field data and synthetic tests on one trend chart and compare test frequency per region.
- WebPageTest: reproduce a regional first-view waterfall with specific test nodes and connection profiles.
- Google Lighthouse: run lab checks per build in CI and review assertion and budget threshold configuration.
Community & Resources
-
Monitoring & Alerting: other coverage in this category.
Official docs and communities -
web.dev: Core Web Vitals — the entry point for metric definitions, thresholds and scope
-
web.dev: LCP — what drives Largest Contentful Paint and how to improve it
-
web.dev: INP — how responsiveness is measured and where it breaks
-
web.dev: CLS — causes and scoring of layout shift
Learning resources and tools
- web-vitals library — the official collection library with reporting examples
- MDN: PerformanceObserver — API reference for custom entry observation
- MDN: Navigator.sendBeacon — reliable reporting during page unload
- Stack Overflow: web-vitals — practical Q&A on collection and attribution
Original source: Datadog Docs ↗