---
title: Browser Session Replay Setup and Configuration
description: >-
  Capture and visually replay your users' web browsing experience with Session
  Replay.
breadcrumbs: >-
  Docs > Session Replay > Browser Session Replay > Browser Session Replay Setup
  and Configuration
---

# Browser Session Replay Setup and Configuration

## Setup{% #setup %}

To set up Session Replay for Browser:

### Step 1 - Set up the Browser SDK{% #step-1---set-up-the-browser-sdk %}

Make sure you've set up the [RUM Browser SDK](https://docs.datadoghq.com/real_user_monitoring/browser/setup.md).

### Step 2 - Enable Session Replay{% #step-2---enable-session-replay %}

To enable Session Replay you have to specify the session replay sample rate. It must be a number between 0.0 and 100.0, where 0 indicates that no replays are recorded and 100 means that all sessions include a replay.

This sample rate is applied in addition to the RUM sample rate. For example, if RUM uses a sample rate of 80% and Session Replay uses a sample rate of 20%, it means that out of all user sessions, 80% are included in RUM, and within those sessions, only 20% have replays. See [Browser RUM & Session Replay sessions](https://docs.datadoghq.com/real_user_monitoring/guide/sampling-browser-plans.md) for more information.

{% tab title="NPM" %}

```javascript
import { datadogRum } from '@datadog/browser-rum';

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

{% /tab %}

{% tab title="CDN async" %}

```javascript
<script>
  window.DD_RUM.onReady(function() {
    window.DD_RUM.init({
      ...
      sessionReplaySampleRate: 100,
      ...
    });
  })
</script>
```

{% /tab %}

{% tab title="CDN sync" %}

```javascript
<script>
    window.DD_RUM && window.DD_RUM.init({
      ...
      sessionReplaySampleRate: 100,
      ...
    });
</script>
```

**Note**: Bellow version v5.0.0, Session Replay does not start automatically and you need to call [`startSessionReplayRecording()`][3] API
{% /tab %}

## Additional configuration{% #additional-configuration %}

### Start or stop the recording manually{% #start-or-stop-the-recording-manually %}

By default, Session Replay starts recording automatically. However, if you prefer to manually start recording at a specific point in your application, you can use the option `startSessionReplayRecordingManually` parameter as shown below, and later call [`startSessionReplayRecording()`](https://datadoghq.dev/browser-sdk/interfaces/_datadog_browser-rum.RumGlobal.html#startsessionreplayrecording). You can also use [`stopSessionReplayRecording()`](https://datadoghq.dev/browser-sdk/interfaces/_datadog_browser-rum.RumGlobal.html#stopsessionreplayrecording) to stop the recording at any time.

{% tab title="NPM" %}

```javascript
import { datadogRum } from '@datadog/browser-rum';

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

datadogRum.startSessionReplayRecording()
// Do something
datadogRum.stopSessionReplayRecording()
```

{% /tab %}

{% tab title="CDN async" %}

```javascript
<script>
  window.DD_RUM.onReady(function() {
    window.DD_RUM.init({
        ...
        startSessionReplayRecordingManually: true,
        ...
    });

    window.DD_RUM.startSessionReplayRecording()
    // Do something
    window.DD_RUM.stopSessionReplayRecording()
  })
</script>
```

{% /tab %}

{% tab title="CDN sync" %}

```javascript
<script>
    window.DD_RUM && window.DD_RUM.init({
        ...
        startSessionReplayRecordingManually: true,
        ...
    });

    window.DD_RUM && window.DD_RUM.startSessionReplayRecording();
    // Do something
    window.DD_RUM && window.DD_RUM.stopSessionReplayRecording();
</script>
```

{% /tab %}

**Note**: In some scenarios, you may want to begin recording, even if it was initially sampled out of replay. To force Session Replay recording for the rest of the current session, call [`startSessionReplayRecording({ force: true })`](https://datadoghq.dev/browser-sdk/interfaces/_datadog_browser-rum.RumGlobal.html#startsessionreplayrecording)

### Privacy options{% #privacy-options %}

Session Replay provides privacy controls to ensure organizations of any scale do not expose sensitive or personal data. See [Privacy Options](https://docs.datadoghq.com/session_replay/browser/privacy_options.md).

### Connect Session Replay to your third-party tools{% #connect-session-replay-to-your-third-party-tools %}

You can access the Session Replay URL to use in integrations, live from the browser where the session is taking place. See [Connect Session Replay to your third-party tools](https://docs.datadoghq.com/real_user_monitoring/guide/connect-session-replay-to-your-third-party-tools.md).

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

- [Use Datadog Session Replay to view real-time user journeys](https://www.datadoghq.com/blog/session-replay-datadog/)
- [Use funnel analysis to understand and optimize key user flows](https://www.datadoghq.com/blog/reduce-customer-friction-funnel-analysis/)
- [Visually replay user-facing issues with Zendesk and Datadog Session Replay](https://www.datadoghq.com/blog/zendesk-session-replay-integration/)
- [Visualize your Product Analytics data in the Analytics Explorer](https://docs.datadoghq.com/product_analytics/analytics_explorer.md)
- [Detect and aggregate CSP violations with Datadog](https://docs.datadoghq.com/integrations/content_security_policy_logs.md)
