Session Replay Wrapper for Segment

Amplitude provides a wrapper to enable a one-line integration between Segment and Amplitude's Session Replay.


This wrapper supports Segment's Amplitude (Actions) destination only.

To use Session Replay with Segment's Amplitude (Classic) destination, use the Session Replay Standalone SDK.

Install the wrapper

Use npm or Yarn to install the package, which includes the Amplitude Session Replay SDK.

1npm install @amplitude/segment-session-replay-wrapper --save

1yarn add @amplitude/segment-session-replay-wrapper


For information about the sessionReplayOptions, see the Session Replay Standalone SDK configuration section.

1import { AnalyticsBrowser } from '@segment/analytics-next';
2import setupAmpSRSegmentWrapper from '@amplitude/segment-session-replay-wrapper';
4export const SegmentAnalytics = AnalyticsBrowser.load({
5 writeKey: SEGMENT_API_KEY,
9 segmentInstance: SegmentAnalytics,
10 amplitudeApiKey: AMPLITUDE_API_KEY,
11 sessionReplayOptions: {
12 logLevel: 4,
13 sampleRate: 1,
14 debugMode: true,
15 },

Segment plugin architecture

This wrapper uses Segment's plugin architecture, which ensures that all track and page events include the required Session Replay ID event property.

User ID to Device ID mapping

Following Segment's documentation, the wrapper maps the Segment user ID to the Amplitude device ID. To find the device ID for replay captures, the wrapper checks if userId is set, and if not, it uses anonymousId.


For troubleshooting information, see Session Replay Standalone SDK | Troubleshooting

Was this page helpful?

Thanks for your feedback!

July 2nd, 2024

Need help? Contact Support


Have a look at the Amplitude Blog

Learn more at Amplitude Academy

© 2024 Amplitude, Inc. All rights reserved. Amplitude is a registered trademark of Amplitude, Inc.