---
title: Configure Your Setup For Browser RUM and Browser RUM & Session Replay Sampling
description: >-
  Learn how to customize your Browser RUM and Browser RUM & Session Replay
  sampling configuration.
breadcrumbs: >-
  Docs > RUM & Session Replay > Real User Monitoring & Session Replay Guides >
  Configure Your Setup For Browser RUM and Browser RUM & Session Replay Sampling
---

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

## Overview{% #overview %}

When instrumenting a [Browser RUM application](https://docs.datadoghq.com/real_user_monitoring/application_monitoring/browser#setup), 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](https://www.datadoghq.com/pricing/?product=real-user-monitoring--session-replay#real-user-monitoring--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{% #setup %}

The `sessionReplaySampleRate` parameter is a percentage of `sessionSampleRate`.

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

{% alert level="info" %}
The Datadog Browser SDK v4.20.0 introduces the `sessionReplaySampleRate` initialization parameter, deprecating the `premiumSampleRate` and `replaySampleRate` initialization parameter.
{% /alert %}

{% alert level="info" %}
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`.

{% /alert %}
When a session is created, RUM tracks it as either:
- [**Browser RUM**](https://www.datadoghq.com/pricing/?product=real-user-monitoring--session-replay#real-user-monitoring--session-replay): Sessions, views, actions, resources, long tasks, and errors are collected.
- [**Browser RUM & Session Replay**](https://www.datadoghq.com/pricing/?product=real-user-monitoring--session-replay#real-user-monitoring--session-replay): Everything from Browser RUM is collected, including replay recordings.

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:

{% collapsible-section open=null %}
## Latest version

```
datadogRum.init({
    ....
    sessionSampleRate: 100,
    sessionReplaySampleRate: 0
});
```

{% /collapsible-section %}

{% collapsible-section %}
before`v4.30.0`
```
datadogRum.init({
    ....
    sampleRate: 100,
    sessionReplaySampleRate: 0
});
```

{% /collapsible-section %}

{% collapsible-section %}
before`v4.20.0`
```
datadogRum.init({
    ....
    sampleRate: 100,
    premiumSampleRate: 0
});
```

{% /collapsible-section %}

{% collapsible-section %}
before`v4.10.2`
```
datadogRum.init({
    ....
    sampleRate: 100,
    replaySampleRate: 0
});
```

{% /collapsible-section %}

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

{% collapsible-section open=null %}
## Latest version

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

{% /collapsible-section %}

{% collapsible-section %}
before`v4.30.0`
```
datadogRum.init({
    ....
    sampleRate: 100,
    sessionReplaySampleRate: 100
});
```

{% /collapsible-section %}

{% collapsible-section %}
before`v4.20.0`
```
datadogRum.init({
    ....
    sampleRate: 100,
    premiumSampleRate: 100
});
```

{% /collapsible-section %}

{% collapsible-section %}
before`v4.10.2`
```
datadogRum.init({
    ....
    sampleRate: 100,
    replaySampleRate: 100
});
```

{% /collapsible-section %}

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.

{% video
   url="https://docs.dd-static.net/images/real_user_monitoring/browser/example-initialization-snippet.mp4" /%}

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.

{% collapsible-section open=null %}
## Latest version

```
datadogRum.init({
    ....
    sessionSampleRate: 60,
    sessionReplaySampleRate: 50
});
```

{% /collapsible-section %}

{% collapsible-section %}
before`v4.30.0`
```
datadogRum.init({
    ....
    sampleRate: 60,
    sessionReplaySampleRate: 50
});
```

{% /collapsible-section %}

{% collapsible-section %}
before`v4.20.0`
```
datadogRum.init({
    ....
    sampleRate: 60,
    premiumSampleRate: 50
});
```

{% /collapsible-section %}

{% collapsible-section %}
before`v4.10.2`
```
datadogRum.init({
    ....
    sampleRate: 60,
    replaySampleRate: 50
});
```

{% /collapsible-section %}

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](https://docs.datadoghq.com/real_user_monitoring/application_monitoring/browser#tagging).

## Further reading{% #further-reading %}

- [Learn about RUM Browser Monitoring](https://docs.datadoghq.com/real_user_monitoring/application_monitoring/browser/)
