Real User Monitoring

Comprehensive guide to real user monitoring for production observability and monitoring systems.

Real User Monitoring (RUM) captures the end-to-end performance of web and mobile applications from the actual user’s perspective. It measures how users experience the application—latency, errors, and interactions—directly from their devices, not from synthetic probes or internal service metrics. RUM matters when application responsiveness affects user retention, conversion, or satisfaction: for high-traffic e-commerce sites, real-time collaboration tools, and mobile-first services where every millisecond counts.

Capturing Real User Data

To begin monitoring real users, embed a lightweight script in the application’s frontend. This script collects performance data as the page loads and during user interactions, then transmits it to a central observability backend.

The script must be minimal and non-blocking. It should initialize early in the page lifecycle, ideally before the first paint. A typical RUM script includes:

<script>
  window.RUM = window.RUM || [];
  RUM.push(['init', {
    endpoint: 'https://observability.example.com/api/v1/rum',
    sampleRate: 0.75,
    traceId: 'x-trace-id',
    userId: 'user-id',
    session: 'session-id'
  }]);
  RUM.push(['track', 'page-load', {
    url: window.location.href,
    referrer: document.referrer,
    timestamp: performance.now(),
    timing: performance.timing
  }]);
</script>

The RUM.push queue pattern allows the script to buffer events even when the network is slow or the backend is down. Each RUM.push call can be a command to start tracking, emit an event, or send data. The init command sets up the configuration, which includes:

Data is sent via fetch or navigator.sendBeacon to ensure delivery even on page unload. The payload is a JSON object with a consistent schema:

{
  "type": "page-load",
  "timestamp": 1712345678.123,
  "url": "https://app.example.com/orders/123",
  "referrer": "https://app.example.com/search?query=widgets",
  "timing": {
    "navigationStart": 1712345670.000,
    "loadEventEnd": 1712345678.123,
    "domContentLoadedEventEnd": 1712345675.432,
    "firstPaint": 1712345671.123,
    "firstContentfulPaint": 1712345672.345,
    "firstMeaningfulPaint": 1712345674.567
  },
  "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36",
  "screen": { "width": 1920, "height": 1080 },
  "network": { "type": "wifi", "effectiveType": "4g", "rtt": 50, "downlink": 15 },
  "traceId": "a1b2c3d4e5f6"
}

Tracking User Interactions

Beyond page loads, RUM captures user actions—clicks, form submissions, scrolls, and custom events. Each interaction is emitted as a track event with a type and metadata.

RUM.push(['track', 'click', {
  element: 'button#checkout',
  target: 'https://app.example.com/checkout',
  timestamp: performance.now(),
  duration: 123,
  properties: {
    category: 'product-card',
    price: 49.99,
    currency: 'USD'
  }
}]);

The duration field is optional but highly recommended. It captures how long the user spent interacting with the element, from mousedown to mouseup, or from click to the next load event. If the interaction triggers a server-side call, the duration can be measured end-to-end.

For complex interactions, use track with start and end events:

RUM.push(['track', 'start', 'form-submit', {
  formId: 'order-form',
  fields: ['name', 'email', 'address'],
  timestamp: performance.now()
}]);

// ... user fills form, clicks submit ...

RUM.push(['track', 'end', 'form-submit', {
  success: true,
  duration: 2100,
  errors: ['email-invalid', 'address-missing'],
  serverLatency: 420,
  timestamp: performance.now()
}]);

This pattern enables granular analysis of user workflows. A form submission that takes 2.1 seconds but has a 420ms server round-trip suggests the frontend took 1.68 seconds to process or render the result.

Correlation with Backend Traces

RUM data becomes powerful when linked to backend service traces. The traceId field is the key. It must be populated early in the frontend and passed to every backend request.

const traceId = window.RUM.traceId || generateTraceId();

fetch('/api/v1/orders', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'X-Trace-Id': traceId
  },
  body: JSON.stringify({ productId: 123 })
})
.then(() => RUM.push(['track', 'submit-order', { traceId, success: true }]));

The backend service uses the X-Trace-Id header to propagate the trace. In a service mesh or distributed tracing setup, this header is passed through all downstream services. Each service adds a span to the trace, and the RUM script can correlate the frontend timeline with the backend trace.

The correlation is not just about timestamps. A page-load event in RUM can be used to look up the corresponding trace in a distributed tracing system. The firstContentfulPaint time can be matched to the backendStart time in the trace. This enables diagnosing issues like “Why is the first contentful paint slow?” by examining the trace for that session.

Sampling and Data Volume Control

RUM generates significant data. A single user session can emit dozens of events. To manage volume and cost, sampling is essential.

Sampling is applied at two levels:

  1. Session sampling: only some user sessions are fully recorded. The sampleRate config key determines this. When a session is sampled, all events in that session are sent to the backend.
  2. Event sampling: within a sampled session, not every event is sent. A eventSampleRate config key can be used to sample events like clicks, scrolls, and form submissions.

The two sampling methods are independent. A session with sampleRate: 0.5 is 50% likely to be recorded. Within that session, eventSampleRate: 0.8 means each event has an 80% chance of being sent.

Sampling can fail silently. If the script is not initialized before window.load, the page-load event might be missed. If RUM.push is called before init, the configuration is applied retroactively. Events sent before init are buffered and processed later, but with potentially incorrect traceId or userId values.

A common failure is incorrect traceId propagation. If the traceId is not set in the init command, or if it is set in a script that runs after fetch, the backend may not correlate frontend and backend traces correctly. The traceId must be set before any HTTP requests are made.

Aggregation and Analysis

The raw RUM data is stored in a time-series or event database. Queries over the data are common:

A typical SQL query over RUM data might look like:

SELECT
  userId,
  COUNT(*) AS session_count,
  AVG(timing.firstContentfulPaint) AS avg_fcp,
  AVG(timing.loadEventEnd) AS avg_load,
  PERCENTILE_CONT(0.75) WITHIN GROUP (ORDER BY timing.loadEventEnd) AS p75_load,
  STRING_AGG(DISTINCT network.type, ',') AS network_types
FROM rum_events
WHERE type = 'page-load'
  AND timestamp >= '2024-04-01T00:00:00Z'
  AND timestamp < '2024-04-02T00:00:00Z'
GROUP BY userId
HAVING AVG(timing.firstContentfulPaint) > 1500
ORDER BY avg_load DESC;

The result can be used to build dashboards showing average performance per user, per device, or per region. Slow sessions can be filtered by network.type to reveal that users on 2g networks have significantly worse firstMeaningfulPaint.

Failure Modes and Edge Cases

RUM is not foolproof. The following silently fail:

A subtle failure is event batching. Events are collected in memory, but if the user closes the tab before the batch is sent, events are lost. The script must use window.addEventListener('beforeunload', ...) to trigger a final sendBeacon call.

Configuration Reference

The full configuration object accepted by RUM.push(['init', ...]) includes:

These settings are not mutually exclusive. A high sampleRate with low eventSampleRate can reduce volume while preserving key user journeys.

Summary

Real User Monitoring is not just a tool—it is a workflow. It starts with a script embedded in the frontend, captures data through page loads and user interactions, correlates with backend traces, and enables analysis at scale. The pattern is consistent: initialize with config, push events, send data via HTTP, and analyze with SQL or visualization tools. The success of RUM hinges on careful configuration, attention to timing, and understanding of how sampling and batching interact. When it breaks, the failure is often silent: events are collected but not sent, traces are mismatched, and performance metrics are incomplete. But when it works, it reveals the true experience of the user—precise, real, and actionable.

This page was rewritten on 18 October 2026. It replaced a templated version that was not specific to its own title. How these pages are written and checked. If anything here is wrong, tell us at [email protected] and we will correct it.