How to Measure Real Page Speed From Real Visitors Instead of Lab Tests

To measure real user page speed you collect timing data in the browser of each visitor and send it to an endpoint you control, then read the aggregated distribution rather than a single average. Lab tests tell you how your site behaves on one synthetic machine with one network profile; field data tells you how it behaves for the people who actually show up, on their devices, on their connections, at their locations. The gap between the two is where most of your perceived slowness lives.

What "real user" measurement actually means

The browser already records the timings you need. The Performance Timeline exposes navigation and resource entries, and the PerformanceObserver interface lets you subscribe to new entries as they are recorded, which matters because some of the most useful metrics only exist after the page has finished loading. The two you will care about most are Largest Contentful Paint, the render time of the biggest element in the viewport, and Interaction to Next Paint, which summarises how long the page takes to respond to clicks, taps and key presses. Both are reported through observers, not through a single synchronous call.

The mechanism for getting them off the visitor's machine is the Beacon API, exposed as navigator.sendBeacon(). It queues a small POST that the browser delivers even if the page is being unloaded, which is exactly the situation you are in when the visitor navigates away or closes the tab. A plain fetch() with keepalive works too and gives you a promise, but the beacon is the simpler and more widely supported path for the final flush.

You need a collector on the other end. That can be a small endpoint on your own infrastructure, a log-based ingestion pipeline, or a third-party Real User Monitoring service. The choice matters less than the discipline of sampling and of not letting the collection itself distort what you are measuring. Keep the payload small and the send asynchronous.

Instrumenting the page to measure real user page speed

Start with the observer. Register it as early as you can in the document so you do not miss entries, and buffer what you collect until the page is hidden or the visitor leaves.

const samples = {};
new PerformanceObserver((list) => {
  for (const e of list.getEntries()) {
    samples[e.name] = e.startTime;
  }
}).observe({ type: 'largest-contentful-paint', buffered: true });

new PerformanceObserver((list) => {
  const last = list.getEntries().at(-1);
  if (last) samples.inp = last.duration;
}).observe({ type: 'event', buffered: true, durationThreshold: 40 });

Then flush on the way out. The visibilitychange event is more reliable than unload on mobile, where the browser may freeze or discard a backgrounded page without ever firing an unload handler.

document.addEventListener('visibilitychange', () => {
  if (document.visibilityState !== 'hidden') return;
  const body = JSON.stringify({
    url: location.pathname,
    lcp: samples['largest-contentful-paint'],
    inp: samples.inp,
    conn: navigator.connection?.effectiveType,
    vw: innerWidth
  });
  navigator.sendBeacon('/rum/collect', new Blob([body], { type: 'application/json' }));
});

The navigator.connection object is not available in every browser, so treat its fields as optional and never let a missing property throw. The same applies to the observers themselves: wrap registration in a feature check so an old browser simply reports nothing rather than breaking the page.

Include the connection type and the viewport width in every sample. Without them you cannot separate a genuinely slow page from a fast page viewed on a slow link, and you will spend weeks optimising server response time for users whose bottleneck is a congested mobile radio.

Reading the data without fooling yourself

Averages are the enemy here. Page load timing distributions are strongly right-skewed: most visits are quick, a long tail is very slow, and the mean sits somewhere in the middle describing nobody. Report percentiles instead, and look at the high ones. The 75th percentile is a common summary because it captures the experience of the slower quarter of your visitors, but the 90th and 95th tell you how bad the tail gets, and the tail is where people abandon.

Segment before you conclude anything. Split by page path, by device class, by connection type, and by whether the visit was a first load or a repeat with a warm cache. A site-wide percentile hides the fact that one template is slow for everyone on one device family. Look at the count in each bucket as well as the percentile, because a 95th percentile computed from a handful of samples is noise.

Watch for the collection pipeline lying to you. If your beacon fires only on visibilitychange, visitors who crash or lose connectivity never report, and your numbers skew optimistic. If your sample rate is high enough to affect performance, you are measuring your measurement. If you are sampling, sample at the session level rather than randomly per page view so that a single visitor's several page views do not dominate.

Correlate the metrics with what you can see in server logs. A high Largest Contentful Paint with a fast time to first byte points at render-blocking resources or a slow image, not at your origin. A high Interaction to Next Paint with a fast initial paint points at long tasks on the main thread, often third-party scripts. The metrics tell you which layer to look at; the network and application logs tell you why.

Where the collection endpoint fits

Your collector should accept the beacon payload, validate its size, and write it somewhere queryable. A minimal endpoint that accepts a JSON body and appends a line to a log is enough to start, and you can run it behind whatever reverse proxy you already use. Set the Content-Type your client sends and reject anything oversized, because a public endpoint that accepts arbitrary payloads will eventually receive them.

If you use a third-party Real User Monitoring service instead, check what it does with sampling, whether it reports percentiles or only averages, and whether it lets you segment by the dimensions above. The vendor's dashboard is only as useful as the questions it lets you ask. Whichever route you take, keep the raw samples long enough to re-analyse them when you change your mind about which percentile matters.

Start by instrumenting a single high-traffic template, confirm that the beacons arrive and that the payloads parse, and only then widen the net. Compare the field percentiles for that template against a lab run of the same page and note where they diverge; that gap is your first real optimisation target, and it is usually more specific than anything a synthetic test will hand you.

Related articles

Subscribe to our newsletter

Get the latest hosting tips, performance insights, and industry news.