# Session Replay Wrapper for Rudderstack

Choose this option if you use Rudderstack for your site&#x27;s analytics.

Source: https://amplitude.com/docs/sdks/session-replay/session-replay-rudderstack-integration

---

On this page

- [Before you begin](#before-you-begin)
- [Install the wrapper](#install-the-wrapper)
- [Use](#use)
- [Rudderstack integration](#rudderstack-integration)
- [Required field mapping](#required-field-mapping)
- [Troubleshooting](#troubleshooting)

# Session Replay Wrapper for Rudderstack

Amplitude provides a wrapper for integrating Rudderstack and Amplitude's Session Replay.

This integration snippet supports [Rudderstack Cloud-mode](https://www.rudderstack.com/docs/destinations/rudderstack-connection-modes/#cloud-mode).

## Before you begin

Use the latest version of the Session Replay SDK, which is {{sdk\_versions:session\_replay\_standalone}}

## Install the wrapper

Use npm or yarn to install the package. This includes the Amplitude Session Replay SDK.

bash

```
npm install @amplitude/session-replay-browser --save

## Use

For information about the `sessionReplayOptions`, see the [Session Replay Standalone SDK configuration](/docs/sdks/session-replay/session-replay-standalone-sdk#configuration) section.

js

import * as sessionReplay from "@amplitude/session-replay-browser";

amplitude.init(AMPLITUDE_API_KEY, user_id, config).promise.then(() => {
      window.rudderAnalytics.ready(function() {
        const rudderAnonymousId = rudderAnalytics.getAnonymousId();

        sessionReplay.init(AMPLITUDE_API_KEY, {
            deviceId: rudderAnonymousId,
            sessionId: rudderAnalytics.getSessionId(),
            sampleRate: .1 // 10% of sessions will be captured 
        }).promise;
        sessionReplay.set(rudderAnalytics.getSessionId());
      });
    }
);

## Rudderstack integration

Amplitude automatically creates the `[Amplitude] Replay Captured` event when Session Replay captures a session. This event is sent directly to Amplitude to link replays with your analytics data. If you don't see this event in Amplitude, contact [Amplitude support](https://gethelp.amplitude.com/hc/en-us/requests/new).

## Required field mapping

Amplitude maps the [Rudderstack Anonymous ID](https://www.rudderstack.com/docs/event-spec/standard-events/identify/#anonymous-id) to the [Amplitude Device ID](/docs/data/troubleshooting/instrumentation-issues#instrumentation-basics), and the [Rudderstack Session ID](https://www.rudderstack.com/docs/sources/event-streams/sdks/session-tracking/) to the [Amplitude Session ID](/docs/data/sources/instrument-track-sessions#how-amplitude-tracks-your-sessions). If you use another field for device ID, contact [Amplitude Support](https://support.amplitude.com).

The session replay ID has the format `<deviceId>/<sessionId>`. Because Session Replay uses `/` as a delimiter, the `deviceId` value can't contain `/`. Accepted characters: `a-z A-Z 0-9 _ - . | @ : =`. Rudderstack's anonymous ID is a UUID, which always complies with these requirements. If you use a custom value for `deviceId`, ensure it follows the accepted character set. If you need an additional character, contact [Amplitude support](https://gethelp.amplitude.com/hc/en-us/requests/new).

## Troubleshooting

Session replay and ad blockers

Session Replay isn't compatible with ad blocking software.

For troubleshooting information, go to [Session Replay Standalone SDK | Troubleshooting](/docs/sdks/session-replay/session-replay-standalone-sdk#troubleshooting)

Was this helpful?

<!--$-->

<!--/$-->
