Configure Your Setup For Browser RUM and Browser RUM & Session Replay Sampling

Overview

When instrumenting a Browser RUM application, set the sample rate for the total amount of user sessions you want to collect and the percentage of user sessions collected that include Browser RUM & Session Replay capabilities.

This guide provides an example of how to customize the amount of Browser RUM & Session Replay sessions you want to collect from the total amount of user sessions in Datadog.

Setup

The sessionReplaySampleRate parameter is a percentage of sampleRate.

This feature requires the Datadog Browser SDK v3.0.0+.

The Datadog Browser SDK v4.20.0 introduces the sessionReplaySampleRate initialization parameter, deprecating the premiumSampleRate and replaySampleRate initialization parameter.

When a session is created, RUM tracks it as either:

  • Browser RUM: Sessions, views, actions, resources, long tasks, and errors are collected. Calls to startSessionReplayRecording() are ignored.
  • Browser RUM & Session Replay: Everything from Browser RUM is collected, including replay recordings. To collect replay recordings, call startSessionReplayRecording().

Two initialization parameters are available to control how the session is tracked:

  • sampleRate controls the percentage of overall sessions being tracked. It defaults to 100%, so every session is tracked by default.
  • sessionReplaySampleRate is applied after the overall sample rate, and controls the percentage of sessions tracked as Browser RUM & Session Replay. It defaults to 100%, so every session is tracked as Browser RUM & Session Replay by default.

To track 100% of your sessions as Browser RUM:

Latest version
datadogRum.init({
    ....
    sampleRate: 100,
    sessionReplaySampleRate: 0
});
beforev4.20.0
datadogRum.init({
    ....
    sampleRate: 100,
    premiumSampleRate: 0
});
beforev4.10.2
datadogRum.init({
    ....
    sampleRate: 100,
    replaySampleRate: 0
});

To track 100% of your sessions as Browser RUM & Session Replay:

Latest version
datadogRum.init({
    ....
    sampleRate: 100,
    sessionReplaySampleRate: 100
});
beforev4.20.0
datadogRum.init({
    ....
    sampleRate: 100,
    premiumSampleRate: 100
});
beforev4.10.2
datadogRum.init({
    ....
    sampleRate: 100,
    replaySampleRate: 100
});

Use the slider to set the percentage of Browser RUM & Session Replay sessions collected from the percentage of total user sessions collected for your application.

If you set sampleRate to 60 and sessionReplaySampleRate to 50, 40% of sessions are dropped, 30% of sessions are collected as Browser RUM, and 30% of sessions are collected as Browser RUM & Session Replay.

Latest version
datadogRum.init({
    ....
    sampleRate: 60,
    sessionReplaySampleRate: 50
});
beforev4.20.0
datadogRum.init({
    ....
    sampleRate: 60,
    premiumSampleRate: 50
});
beforev4.10.2
datadogRum.init({
    ....
    sampleRate: 60,
    replaySampleRate: 50
});

For more information about tagging and exploring attributes, see Browser Monitoring.

Further reading

Additional helpful documentation, links, and articles: