Track flow screen views in iOS SDK
Every time a user opens a screen in a flow, the SDK reports a flow_screen_showed event to your app. Forward it to Amplitude, Mixpanel, or whichever product analytics you run, so you can analyze flow screens together with the rest of your app’s events.
To see how far users get through a flow, you don’t need any code — flow metrics already show views, completions, and per-screen drop-off in the Adapty Dashboard. Use this guide when you need the same data in your own analytics, joined with events Adapty doesn’t know about.
Before you start
You need:
- Adapty iOS SDK v4 or later: The flow analytics callback doesn’t exist in earlier versions.
- A flow version published after this feature shipped: Adapty generates the screen events when it publishes a flow, so a flow you last published before then reports nothing. If no events reach your app, publish a new version of the flow and try again.
What you receive
A flow reports flow_screen_showed every time a user opens one of its screens. Adapty counts these events in its own flow analytics and delivers them to your app as well, so you can build the same funnel in your own analytics.
| Parameter | Description |
|---|---|
instanceId | The ID of the screen the user opened. |
screen_order | The screen’s position in the flow. |
is_last_screen | true when the screen has nowhere further to go. A branching flow can end on several different screens, and each one reports true. |
Both isBackendEvent and isCustomerEvent are true on this event: Adapty keeps counting it, and your app receives it too.
Screen views reach the same analytics callback as every other flow event. See Handle flow & paywall events for where to register it.
Forward every screen view to your analytics
Match on the event name before you read anything else, because a flow reports other events through the same callback.
func flowController(
_ controller: AdaptyFlowController,
didReceiveAnalyticEvent name: String,
params: [String: any Sendable]
) {
guard name == "flow_screen_showed" else { return }
let screenId = params["instanceId"] as? String
let screenOrder = params["screen_order"] as? Int
// Send screenId and screenOrder to your analytics provider here.
}
Run code when a user reaches the end
is_last_screen is true on a screen the flow can’t advance past. Use it to unlock content, mark onboarding as done, or send a completion event of your own, without adding a button action in the builder for it.
func flowController(
_ controller: AdaptyFlowController,
didReceiveAnalyticEvent name: String,
params: [String: any Sendable]
) {
guard name == "flow_screen_showed",
params["is_last_screen"] as? Bool == true
else { return }
// The user reached the end of the flow.
}
Reaching the last screen is not the same as closing the flow. A user can see the final screen and dismiss the flow without acting on it, and a branching flow can end on several different screens. To know that the flow itself went away, use flowControllerDidDisappear in UIKit, or the didDisappear closure in SwiftUI instead.