This article covers the installation of Session Replay using the Session Replay iOS Segment plugin. If your app is already instrumented with Segment using their Analytics-Swift library and Amplitude (Actions) destination, use this option.
If your app is already instrumented with an Amplitude iOS SDK, use the Session Replay iOS SDK Plugin.
If you use Segment using other options, choose the standalone implementation.
Amplitude built Session Replay to minimize impact on the performance of the iOS apps in which it's installed by:
Session Replay captures changes to an app's view tree, this means the main view and all it's child views recursively. It then replays these changes to build a video-like replay. For example, at the start of a session, Session Replay captures a full snapshot of the app's view tree. As the user interacts with the app, Session Replay captures each change to the view as a diff. When you watch the replay of a session, Session Replay applies each diff back to the original view tree in sequential order, to construct the replay. Session replays have no maximum length.
To report issues with Session Replay for iOS, see the AmplitudeSessionReplay-ios GitHub repository.
Use the latest version of the Session Replay iOS Segment Plugin above 0.1.3
.
The Session Replay iOS Segment Plugin requires that:
Session replay supports a minimum target version of iOS 13. Over 91% of Apple devices are running iOS 16 or later, per App Store statistics.
Add the latest version of the plugin to your project dependencies.
dependencies: [ .package(url: "https://github.com/amplitude/AmplitudeSessionReplay-iOS", .branch("main"))]
For integrating with Analytics-Swift
, use the AmplitudeSegmentSessionReplayPlugin
target.
.product(name: "AmplitudeSegmentSessionReplayPlugin", package: "AmplitudeSessionReplay")
pod 'AmplitudeSessionReplay', :git => 'https://github.com/amplitude/AmplitudeSessionReplay-iOS.git'pod 'AmplitudeSegmentSessionReplayPlugin', :git => 'https://github.com/amplitude/AmplitudeSessionReplay-iOS.git'
Configure your application code:
import AmplitudeSegmentSessionReplayPluginimport Segmentimport SegmentAmplitude // Initialize Segmentlet analytics = Analytics(configuration: config) // Ensure Segment's AmplitudeSession plugin is added before AmplitudeSegmentSessionReplayPluginanalytics.add(plugin: AmplitudeSession()) // Initialize AmplitudeSegmentSessionReplayPlugin with your Amplitude API keyanalytics.add(plugin: AmplitudeSegmentSessionReplayPlugin(amplitudeApiKey: API_KEY, sampleRate: 0.1))
Pass the following option when you initialize the Session Replay plugin:
Name | Type | Required | Default | Description |
---|---|---|---|---|
apiKey |
String |
No | null |
Sets the Amplitude API Key. |
deviceId |
string |
Yes | undefined |
Sets an identifier for the device running your application. |
sessionId |
number |
Yes | undefined |
Sets an identifier for the users current session. The value must be in milliseconds since epoch (Unix Timestamp). |
sampleRate |
number |
No | 0 |
Use this option to control how many sessions to select for replay collection. The number should be a decimal between 0 and 1 (for example, 0.4 ), representing the fraction of sessions to have randomly selected for replay collection. Over a large number of sessions, 0.4 would select 40% of those sessions. |
optOut |
boolean |
No | false |
Sets permission to collect replays for sessions. Setting a value of true prevents Amplitude from collecting session replays. |
logger |
Logger |
No | ConsoleLogger |
Sets a custom logger class from the Logger to emit log messages to desired destination. Set to null to disable logging. |
serverZone |
string |
No | US |
EU or US. Sets the Amplitude server zone. Set this to EU for Amplitude projects created in EU data center. |
enableRemoteConfig |
boolean |
No | true |
Enables or disables remote configuration for this instance of Session Replay. |
serverUrl |
string |
No | null |
Explicitly set the server URL. Use this setting for proxy configuration. |
Enable remote configuration to set Sample Rate and Masking Level in Amplitude.
When you enable remote configuration, settings you define in Amplitude take precedence over settings you define locally in the SDK. As a result, while testing your application, you should disable remote configuration to ensure you can set sampleRate
to 1
, and ensure you capture test sessions.
Session Replay supports three ways to block sensitive on-screen data.
Session Replay for iOS supports three levels of masking, configurable with the the maskLevel
config option.
Use this option in the Session Replay configuration.
Mask level | Description |
---|---|
light |
Masks all password, email address, credit card numbers, phone numbers and web views. |
medium |
Masks all editable text views and web views. |
conservative |
Masks all text views and web views. |
Session Replay provides an extension on UIView
to manage privacy. Import the Session Replay library to access it.
import AmplitudeSessionReplay
Variable | Description |
---|---|
amp_isBlocked |
Set view.amp_isBlocked to selectively replace a view and its subviews with a placeholder in session replays. UITextViews and UITextFields are automatically blocked. To unblock a view that is masked by default, set the this value to false |
Session Replay provides an extension on View
to manage privacy. Import the Session Replay Library to access it.
import AmplitudeSessionReplay
Modifier | Description |
---|---|
amp_setBlocked(_ blocked: Bool) |
Add the amp_setBlocked() modifier to a View to selectively replace a view and its subviews with a placeholder in session replays. To unblock a view that is masked by default, set the this value to false |
Set optOut
on the plugin to indicate a user has opted out of session replay.
// Pass a boolean value to indicate a users opt-out statusamplitudeSegmentSessionReplayPlugin.optOut = true
Session Replay is available to Amplitude Customers who use the EU data center. Set the serverZone
configuration option to EU
during initialization. For example:
// Set serverZone on the AmplitudeSegmentSessionReplayPluginlet plugin = AmplitudeSegmentSessionReplayPlugin(amplitudeApiKey: API_KEY, sampleRate: 0.1, serverZone: .EU)
By default, Session Replay captures 0% of sessions for replay. Use the sampleRate
configuration option to set the percentage of total sessions that Session Replay captures. For example:
To set the sampleRate
consider the monthly quota on your Session Replay plan. For example, if your monthly quota is 2,500,000 sessions, and you average 3,000,000 monthly sessions, your quota is 83% of your average sessions. In this case, to ensure sampling lasts through the month, set sampleRate
to .83
or lower.
Keep the following in mind as you consider your sample rate:
.01
. If this value doesn't capture enough replays, raise the rate over the course of a few days. For ways to monitor the number of session replays captured, see View the number of captured sessions.// This configuration samples 1% of all sessionsamplitude.add(plugin: AmplitudeSegmentSessionReplayPlugin(amplitudeApiKey: API_KEY, sampleRate: 0.01))
Once enabled, Session Replay runs on your app until either:
analytics.remove(plugin: amplitudeSegmentSessionReplayPlugin)
Call analytics.remove(plugin: amplitudeSegmentSessionReplayPlugin)
before a user navigates to a restricted area of your app to disable replay collection while the user is in that area.
This requires keeping a reference to the SessionReplayPlugin instance let amplitudeSegmentSessionReplayPlugin = AmplitudeSegmentSessionReplayPlugin(/* session replay options */)
.
Call amplitude.add(plugin: amplitudeSegmentSessionReplayPlugin)
to re-enable replay collection when the return to an unrestricted area of your app.
You can also use a feature flag product like Amplitude Experiment to create logic that enables or disables replay collection based on criteria like location. For example, you can create a feature flag that targets a specific user group, and add that to your initialization logic:
import AmplitudeSwiftimport AmplitudeSwiftSessionReplayPlugin // Your existing initialization logic with Segementlet analytics = Analytics(configuration: config)analytics.add(plugin: AmplitudeSession()) if (nonEUCountryFlagEnabled) { // Create and Install Session Replay Plugin let amplitudeSegmentSessionReplayPlugin = AmplitudeSwiftSessionReplayPlugin(sampleRate: 0.1) analytics.add(plugin: amplitudeSegmentSessionReplayPlugin)}
By default, Session Replay blocks web views in a capture. To enable capture of WebView components, use the settings described in Block on-screen data.
Session Replay supports capturing map views in iOS applications. To enable map view capture, unmask the map view in your implementation.
Session replay uses existing Amplitude tools and APIs to handle privacy and deletion requests.
While privacy laws and regulations vary across states and countries, certain constants exist, including the requirements to disclose in a privacy notice the categories of personal information you are collecting, the purposes for its use, and the categories of third parties with which personal information is shared. When implementing a session replay tool, you should review your privacy notice to make sure your disclosures remain accurate and complete. And as a best practice, review your notice with legal counsel to make sure it complies with the constantly evolving privacy laws and requirements applicable to your business and personal information data practices.
If your Amplitude plan includes Session Replay, Amplitude retains raw replay data for 30 days from the date of ingestion.
If you purchase extra session volume, Amplitude retains raw replay data for 90 days from the date of ingestion. If you need a more strict policy, contact Amplitude support to set the value to 30 days.
Changes to the retention period impact replays ingested after the change. Sessions captured and ingested before a retention period change retain the previous retention period.
Retention periods are set at the organization level. Replays that are outside of the retention period aren't viewable in Amplitude.
The Amplitude DSAR API returns metadata about session replays, but not the raw replay data. All events that are part of a session replay include a [Amplitude] Session Replay ID
event property. This event provides information about the sessions collected for replay for the user, and includes all metadata collected with each event.
{ "amplitude_id": 123456789, "app": 12345, "event_time": "2020-02-15 01:00:00.123456", "event_type": "first_event", "server_upload_time": "2020-02-18 01:00:00.234567", "device_id": "your device id", "user_properties": { ... } "event_properties": { "[Amplitude] Session Replay ID": "cb6ade06-cbdf-4e0c-8156-32c2863379d6/1699922971244" } "session_id": 1699922971244,}
Session Replay uses Amplitude's User Privacy API to handle deletion requests. Successful deletion requests remove all session replays for the specified user.
When you delete the Amplitude project on which you use Session Replay, Amplitude deletes that replay data.
Session Replay uses the same block filter available in the Amplitude app. Session Replay doesn't block traffic based on event or user properties.
If a user opts out tracking in your app, use the optOut
configuration option to disable replay collection for that user.
Session Replay temporarily stores replay data data on the file system before it is uploaded. At every initialization, the least recent replays are trimmed to bring the total disk usage down to a maximum size.
Keep the following limitations in mind as you implement Session Replay:
Session Replay doesn't stitch together replays from a single user across multiple projects. For example:
The User Sessions chart doesn't show session replays if your organization uses a custom session definition.
Session Replay cannot capture the following iOS views:
March 18th, 2025
Need help? Contact Support
Visit Amplitude.com
Have a look at the Amplitude Blog
Learn more at Amplitude Academy
© 2025 Amplitude, Inc. All rights reserved. Amplitude is a registered trademark of Amplitude, Inc.