Session Replay for iOS lets you visually replay your user's app interactions, providing powerful qualitative insights to complement your quantitative analytics.
Mixpanel Session Replay enables you to quickly understand why users behave a certain way in your app, complementing analytics insights on where they drop off.
- Active Mixpanel account (Enterprise)
- Mixpanel Swift SDK
v4.3.1
or later
Add the Session Replay SDK using Swift Package Manager directly in Xcode:
- In Xcode, go to File → Add Package Dependencies...
- Paste the GitHub URL:
https://github.com/mixpanel/mixpanel-ios-session-replay-package
- Follow the prompts to select the latest version and add the package to your project.
Open podfile and add Mixpanel Session Replay library to your dependencies:
target 'MyApp' do
pod 'MixpanelSessionReplay', :git => 'https://github.com/mixpanel/mixpanel-ios-session-replay-package.git', :tag => 'v0.3.3'
end
Install the Mixpanel Session Replay by running the following in the Xcode project directory:
pod install
import Mixpanel
import MixpanelSessionReplay
struct YourApp: App {
@Environment(\.scenePhase) private var scenePhase
var body: some Scene {
WindowGroup {
ContentView()
}
.onChange(of: scenePhase) {
if scenePhase == .active {
let config = MPSessionReplayConfig(wifiOnly: false, recordSessionsPercent: 100.0)
MPSessionReplay.initialize(token: Mixpanel.mainInstance().apiToken,
distinctId: Mixpanel.mainInstance().distinctId,
config: config)?.startRecording()
}
}
}
}
import UIKit
import Mixpanel
import MixpanelSessionReplay
@main
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool {
Mixpanel.initialize(token: "YOUR_MIXPANEL_TOKEN")
let config = MPSessionReplayConfig(wifiOnly: false, recordSessionsPercent: 100.0)
MPSessionReplay.initialize(token: Mixpanel.mainInstance().apiToken,
distinctId: Mixpanel.mainInstance().distinctId,
config: config)
#if DEBUG
MPSessionReplay.getInstance()?.loggingEnabled = true
#endif
return true
}
func applicationDidBecomeActive(_ application: UIApplication) {
MPSessionReplay.getInstance()?.startRecording()
}
}
Customize your session replay by modifying MPSessionReplayConfig
:
wifiOnly
: Restricts uploads to WiFi connections (default:true
).recordSessionsPercent
: Controls session sampling from0.0
(none) to100.0
(all).autoMaskedViews
: Automatically masks sensitive views (Image
,Text
,Web
by default).autoCapture
: Controls automatic screenshot capture:.enabled
(default),.viewControllerLifecycle
,.touch
, or.disabled
.
If auto capture is disabled, trigger screenshots manually:
MPSessionReplay.getInstance()?.captureScreenshot()
By default, Mixpanel automatically masks sensitive views:
- All text fields (cannot be unmasked)
- Images, labels, WebViews (can be manually adjusted)
To manually control sensitivity:
// SwiftUI
Image("photo").mpReplaySensitive(true)
// UIKit
yourUIView.mpReplaySensitive = true
Questions or feedback? Contact your Mixpanel Account Manager.