# Collect browser telemetry
Corridora browser real user monitoring (RUM) connects page performance, browser errors, and network requests to a browser session. Add the agent to the pages you want to observe, then instrument your backend to follow a request across both sides of the connection.
This guide uses the hosted browser script. Start with [core concepts](../start/concepts.md) for service and session terminology, or the [documentation home](../README.md) for other collection methods.
## Create a browser application
1. Select the organization that should receive the data.
2. Open **Configuration → Keys**, select **RUM**, and choose **Add RUM application**.
3. Enter a stable service name, such as `storefront-web`, and select **Save**.
4. Copy the generated installation tag while the key is displayed. The dashboard does not display the key again.
Use the generated RUM key for this browser application. It authenticates ingestion and is intentionally visible to visitors in the page source and network requests. Do not put a dashboard API key in a browser page.
Give backend producers their own ingest keys in the same organization. Separate browser and backend credentials let you rotate them independently; keys from different organizations do not correlate simply because they use the same ingest URL.
## Install the script
Place the tag before `` on each page you want to observe. A site-wide template is usually the simplest place. Replace `YOUR_RUM_INGEST_KEY` with the generated key, preserving its URL encoding in `ckid`.
```html
```
Use the endpoint from your installation tag if it differs from this example. `data-endpoint` is an ingest **base URL**; the agent appends `/v1/logs` and `/v1/traces`. The browser exports OTLP/HTTP JSON only. Omit `data-encoding` or set it to `json`. Existing installations using `data-encoding="protobuf"` or programmatic `encoding: "protobuf"` must remove that setting; protobuf settings fail initialization. See the [ingest reference](../reference/ingest.md) for authentication and signal endpoints.
| Setting | Meaning |
| --- | --- |
| `ckid` in the script URL | RUM key used to load the hosted agent and authenticate telemetry. |
| `data-endpoint` | Required ingest base URL. Without it, the script does not initialize automatically. |
| `data-service` | Browser application `service.name`. Defaults to the page hostname if omitted. Set it explicitly to keep service identity stable. |
| `data-consent` | `pending` (default), `granted` or `denied`. Missing or unrecognized values stay pending. Supply `granted` only after a current analytics decision from your consent platform. |
| `data-service-namespace` | Optional `service.namespace` for grouping related services. |
| `data-env` | `deployment.environment.name`; defaults to `production` for script installation. Set `staging` or another value explicitly outside production. |
| `data-version` | Optional `service.version`, such as a release identifier. |
| `data-trace-origins` | Comma-separated HTTPS API origins that may receive trace context. Same-origin requests are eligible automatically. |
The agent also accepts `data-key`, which takes precedence over the key in the script URL for ingestion. Keep `ckid` in a hosted script URL: the script service checks it before serving the asset. Using the generated tag avoids mismatched keys.
An unknown, disabled, revoked, or non-RUM key returns `404` when loading the hosted script. Rolling a key requires updating the installation tag; the old installation stops working with the old key.
## Connect your consent platform
The installed tag creates an inactive controller. While consent is `pending` or `denied`, Corridora does not access session storage, create a session, instrument the page, inject trace headers or collect telemetry. Your consent management platform (CMP) owns the banner, analytics purpose, saved choices, evidence, expiry and preference controls. Forward its current choice and every later change to Corridora, including withdrawal and changes made in another tab.
Use an application-owned adapter for your CMP. The following example assumes the adapter has a synchronous `current()` method returning `pending`, `granted` or `denied`, and `subscribe(callback)` for all changes. Implement those methods against your actual consent platform; they are not part of the Corridora bundle. Run this code after the hosted script has loaded, for example in a module initializer (``) placed after the installation tag:
```js
import { analyticsConsent } from "./consent-preferences.js";
function syncConsent() {
let decision = "pending";
try {
decision = analyticsConsent.current();
} catch {
// A failed or unavailable CMP leaves analytics inactive.
}
void window.CorridoraRum.setConsent(decision).catch(() => {
console.error("RUM consent transition failed");
});
}
analyticsConsent.subscribe(syncConsent);
syncConsent();
```
`window.CorridoraRum.getConsent()` reports the current choice. `setConsent("denied")` immediately closes collection and transport gates; its promise completes after cleanup and removal of this service's session entry. It discards queued telemetry and prevents retries. A later grant starts a fresh session. Use the same API for an expired or withdrawn decision; do not replace withdrawal with `shutdown()`, which drains authorized queued data.
Loading the bundle still requests an asset from its script host. If your policy also requires avoiding that request before consent, have the CMP defer insertion of the script. Re-read its current choice when loading finishes, then keep forwarding subsequent changes. Removing a loaded script tag does not stop its runtime.
Late grants do not backfill earlier activity. Resource, request and long-task records must begin after the grant. The current consent-aware runtime omits document navigation timing and Web Vitals observers entirely, because they can include earlier activity or lifetime aggregates.
### Coordinate existing browser OpenTelemetry
The agent initializes browser OpenTelemetry providers only after consent is granted. If your page already loads another browser OpenTelemetry SDK, choose which initialization owns the providers and exporters before installing Corridora. Loading two SDKs independently can leave one using the other's exporters or produce duplicate instrumentation. Corridora's consent controls do not control that other SDK's collection.
When Corridora is intended to own the providers, coordinate or disable the competing SDK, and start Corridora only after a current analytics grant. Loading the inactive controller first does not reserve provider ownership. A deferred tag can execute after another SDK's synchronous script even when it appears earlier in the HTML; script order alone does not establish consent or provider ownership.
After changing order, verify fresh logs and traces reach the intended Corridora organization and that browser/backend trace IDs match. Successful script loading alone does not verify provider ownership or exporter routing.
## Allow the browser connections
For a site with a Content Security Policy, add the script host to `script-src` and the ingest host to `connect-src`. Preserve the other sources and nonce or hash requirements your application already uses. For the hosted endpoints, the relevant additions are:
```text
script-src … https://rum.corridora.ai;
connect-src … https://ingest.corridora.ai;
```
The ellipses indicate your existing policy entries; this is not a complete policy to copy verbatim. If you use different hosts, allow those hosts instead. Your application's API requests must also be allowed by its `connect-src` policy.
Telemetry POSTs include these headers:
```text
Content-Type: application/json
X-CORRIDORA-KEY: YOUR_RUM_INGEST_KEY
X-Corridora-Ingest-Source: rum
```
An ingest endpoint or proxy receiving cross-origin browser exports must answer CORS preflights and permit these headers and `POST` from your site's origin. A successful command-line request does not verify browser CORS configuration.
## Connect browser and backend traces
The agent records fetch and XMLHttpRequest spans. It injects a fresh `traceparent` header into eligible requests:
- Same-origin requests are eligible without extra configuration.
- Cross-origin requests are eligible only for configured HTTPS origins. Use exact origins, including a nonstandard port when applicable; wildcard hosts are unsupported.
- Fetch requests using `mode: "no-cors"` and telemetry exporter requests do not receive injected trace context.
For an application at `https://shop.example.com` calling `https://api.example.com`, set `data-trace-origins="https://api.example.com"`. The API's CORS policy must allow `traceparent` in addition to the request's existing headers and methods. Preserve any credentialed CORS settings your application needs.
Instrument the API to extract W3C trace context and export its server spans to the same Corridora organization. Merely allowing the header does not create backend spans. The browser propagates `traceparent`; it does not propagate `tracestate` or `baggage` through its injector. On eligible requests it replaces caller-supplied trace context headers with its current context.
Verify the connection with the [browser-to-backend investigation](../../operator/investigate/browser-to-backend.md).
## Know what is enabled
All collection waits for analytics consent. After a grant, performance, network tracing and error collection are enabled by default. Console, user-action, interaction and DOM mutation capture are disabled in this release, even when explicitly requested; enabling them in a later release needs a separate content-capture purpose and gate.
| Collection | Default | Programmatic option |
| --- | --- | --- |
| Navigation events (document navigation timing omitted) | On | `documentLoad` |
| Single-page application navigation | On | `spa` |
| Web Vitals: LCP, CLS, INP, FCP, TTFB | Omitted | `webVitals` |
| Resource timing | On | `resources` |
| Fetch spans | On | `fetch` |
| XMLHttpRequest spans | On | `xhr` |
| Uncaught exceptions and unhandled rejections | On | `errors` |
| Console `warn` and `error` logs | Unavailable | `console` |
| User-action click logs | Unavailable | `userActions` |
| Long-task observations, where supported | Off | `longTasks` |
| Click, input, and focus interaction spans | Unavailable | `interactions` |
| DOM mutation spans | Unavailable | `domMutations` |
Script attributes can toggle the available collection switches: `data-document-load`, `data-spa`, `data-resources`, `data-fetch`, `data-xhr`, `data-errors` and `data-long-tasks`. Use `"true"` to enable or `"false"` to disable; the values `"1"` and `"yes"` also enable an option. An empty present flag enables the option; an absent flag retains its default. Unknown boolean values fail initialization. `data-web-vitals` and content-capture flags remain accepted for compatibility but cannot enable those unavailable features. `data-trace-sample-rate` accepts 0–1 and `data-encoding` accepts only `json`, which is also the default when omitted. Other encoding values fail initialization. `data-debug="true"` logs navigation diagnostics to the console after consent.
Use programmatic configuration for custom URL redaction or a bounded `onDiagnostic` callback. `window.CorridoraRum.getInitializationStatus()` reports `idle`, `pending`, `denied`, `ready` or `failed` without logging secrets. Read [data privacy and lifecycle](data-privacy.md) before enabling collection.
## Configure initialization in JavaScript
For configuration beyond script attributes, load the hosted bundle without `data-endpoint`, then initialize it from your own JavaScript. Omitting `data-endpoint` prevents automatic initialization. The `ckid` is still required to load the hosted bundle.
```html
```
For example, `/assets/observability.js` can contain:
```js
const agent = window.CorridoraRum?.init({
endpoint: "https://ingest.corridora.ai",
ingestKey: "YOUR_RUM_INGEST_KEY",
serviceName: "storefront-web",
consent: "pending",
resourceAttributes: {
"service.namespace": "commerce",
"deployment.environment.name": "production",
"service.version": "2026.09.28",
},
tracePropagationOrigins: ["https://api.example.com"],
traceSampleRate: 0.25,
plugins: {
console: false,
userActions: false,
interactions: false,
domMutations: false,
longTasks: true,
},
});
```
Serve the initializer from a location allowed by your CSP, then connect the returned controller to your CMP using `agent.setConsent` as described above. Install one agent per page. Repeated `init` calls return the same controller; they do not change configuration or consent. The agent manages the page's OpenTelemetry providers after a grant, so coordinate it with any existing browser OpenTelemetry setup.
`traceSampleRate` accepts a number from `0` to `1` and defaults to `1`. It controls root trace sampling; child spans follow their parent's decision. A rate of `0.25` samples approximately a quarter of root traces, not exactly one in every four requests. Request-error logs are derived from recorded error spans and follow trace sampling. Exception logs are collected independently of that setting; document Web Vitals are omitted in this release.
For a deliberate reconfiguration, shut down the existing agent before calling `init` again:
```js
await agent?.forceFlush();
await agent?.shutdown();
```
Keep the returned agent reference in your application's initialization code when you need lifecycle control. Shutdown stops recording, stops Corridora plugins, and drains exporters. Some browser observers retain inactive listeners; shutdown is not a promise to remove every underlying browser listener.
## Understand sessions and page context
After consent is granted, each record carries a `session.id` stored in tab-scoped `sessionStorage`. Every grant starts a fresh session, including a grant after reloading the page. Withdrawal removes this service's session entry, and a later grant cannot resume an earlier session. When storage is unavailable, the active page keeps its session identifier in memory. Sessions rotate after 30 minutes of inactivity or 24 hours total; trusted activity and navigation renew activity, while background telemetry does not. Call `agent.resetSession()` on application logout. These are not user identities or authentication sessions.
`browser.document.url.full` identifies the page when a span starts or a log is emitted. A network span's `url.full` identifies its request target. These can differ: a request to an API should remain associated with the page that initiated it, even if the application navigates before the response arrives.
Previously captured interaction and mutation spans use the same session and share node identifiers within a page initialization. Their DOM format uses bounded initial/checkpoint snapshots and subtree operations with inherited masking. Event/byte budgets, sequence gaps and sampling can make reconstruction partial; it does not guarantee visual fidelity. This release does not create new interaction or mutation spans.
The default browser context manager is synchronous. If manual application spans require parentage across asynchronous work, manage that context explicitly in your application's instrumentation.
## Validate the installation
1. Open a page with the installed tag and inspect the browser's Network panel. Confirm that `corridora-rum.js` loads successfully.
2. Before a grant, confirm there is no Corridora session entry, trace injection or telemetry POST. Grant the analytics purpose through your CMP, then make a normal application request and navigate through a representative page. Look for POSTs to `/v1/logs` and `/v1/traces`. The agent normally batches up to 20 records with a one-second scheduled delay.
3. Inspect a telemetry payload. Confirm `service.name`, environment, version, `session.id`, and the sanitized page URL. Check for sensitive values before expanding collection.
4. Open **Experience → Sessions** with the matching service and a time range covering the visit. Document Web Vitals are omitted in this release, so absence from **Experience → Vitals** can be expected.
5. For a configured API origin, confirm the request carries `traceparent`, the API accepts the request, and the corresponding server span appears in the trace.
6. Withdraw analytics consent through the CMP. Confirm collection and retries stop, queued data is discarded, and only this service's session entry is removed. Repeat after granting again, including changes made in another tab.
If the script or exports fail, use [missing-data troubleshooting](../troubleshoot/missing-data.md). Check the browser console for CSP and CORS failures, verify the key remains active, and confirm the selected organization and service.
## Interpret collection limits
Fetch spans finish after the cloned response body has been consumed. Streaming requests can remain open until the stream ends. HTTP `4xx`/`5xx` responses and transport failures create error spans and correlated request-error logs; an aborted request is treated as cancellation rather than an error span.
Resource timing retains same-origin records and the slowest 25 cross-origin or unknown-origin candidates per drain, with classification before URL redaction. Optional mutations, interactions, actions and console capture share a 40-event and 64 KiB budget per second. Replay checkpoints are bounded to 300 nodes and 24 KiB, with added subtrees bounded to 8 KiB. Drops, truncation and trace sampling make reconstruction explicitly partial. See [data privacy and lifecycle](data-privacy.md) for masking, redaction, and optional capture controls.
The agent flushes periodically and when a page becomes hidden or receives `pagehide`. Export uses authenticated requests with browser keepalive where possible and retries retryable failures. Browser shutdown, network loss, and browser request limits can still prevent delivery; a session view is not a guaranteed complete history of every page event.