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 sessionSampleRate.

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.
The Datadog Browser SDK v5.0.0 introduces two major behavior changes:
  • Only sessions that have recorded a replay are considered as Browser RUM & Session Replay
  • The sessionReplaySampleRate initialization parameter default value is 0 . Previous versions of the SDK use 100.
When a session is created, RUM tracks it as either:

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

  • sessionSampleRate 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. From Datadog Browser SDK v5.0.0, it defaults to 0, so no session is tracked as Browser RUM & Session Replay by default.

To track 100% of your sessions as Browser RUM:

Latest version
datadogRum.init({
    ....
    sessionSampleRate: 100,
    sessionReplaySampleRate: 0
});
beforev4.30.0
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({
    ....
    sessionSampleRate: 100,
    sessionReplaySampleRate: 100
});
beforev4.30.0
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 sessionSampleRate 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({
    ....
    sessionSampleRate: 60,
    sessionReplaySampleRate: 50
});
beforev4.30.0
datadogRum.init({
    ....
    sampleRate: 60,
    sessionReplaySampleRate: 50
});
beforev4.20.0
datadogRum.init({
    ....
    sampleRate: 60,
    premiumSampleRate: 50
});
beforev4.10.2
datadogRum.init({
    ....
    sampleRate: 60,
    replaySampleRate: 50
});

From v5.0.0, to track 100% of the sessions that reach a custom state as Browser RUM & Session Replay:

datadogRum.init({
    ....
    sessionSampleRate: 100,
    sessionReplaySampleRate: 100,
    startSessionReplayRecordingManually: true,
});

// when the custom state is reached
datadogRum.startSessionReplayRecording()

With the use of startSessionReplayRecordingManually: true, sessions that do not call startSessionReplayRecording() are considered as Browser RUM.

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

Further reading

Additional helpful documentation, links, and articles:

PREVIEWING: rtrieu/product-analytics-ui-changes