User data
Event Listener
Unflow automatically tracks a number of events when a user interacts with Unflow content.
Name | Description |
---|---|
screen_viewed | Tracked the first time a screen has been shown to the user. |
screen_transitioned | Tracked when a user swipes or taps to progress to the next page, or back to a previous page. |
screen_dismissed | Tracked when the user closes the screen. |
opener_tapped | Tracked when the user clicks on an opener in a space. |
button_tapped | Tracked when a user taps a button. |
rating_response | Tracked when a user submits a rating. |
page_appear | Tracked when a story page appears |
page_disappear | Tracked when a story page disappears |
question_answered | Tracked when an option is selected from a question block |
These events can be received on device via an AnalyticsListener
. The listener can be configured to return instances of UnflowEvent
to be handled within your own app.
The listener also provides you with a dictionary, or map, of the attributes we have set. If you're using flows, you'll find that sometimes the flow will set an attribute itself, so its useful to manually store this somewhere in your app too. For example, an onboarding flow may set a reason for them joining, and it would be very useful to store that yourself.
// Implement the AnalyticsListener delegate class
class UnflowAnalyticsListener: AnalyticsListener {
func onEvent(event: UnflowEvent) {
// Do something with the event
print("Unflow-Analytics: \(event)")
}
func onAttributesUpdate(attributes: [String: UnflowUI.UnflowAnalyticsValue]) {
// Do something with the attributes
print("Unflow-Attributes: \(attributes)")
}
}
// Register the AnalyticsListener when initializing the SDK
UnflowSDK.initialize(
config: UnflowSDK.Config(apiKey: "<YOUR_API_KEY>", enableLogging: false),
analyticsListener: UnflowAnalyticsListener()
)
Metadata
Context is associated with each of the UnflowEvent
objects received allowing for further contualation of the event. The metadata for each type is as follows.
Event | Key | iOS Type | Android Type | Notes |
---|---|---|---|---|
screen_viewed | screen_id | Int | Long | |
page_count | Int | Long | Stories only. | |
screen_transitioned | screen_id | Int | Long | |
page_id | Int | Long | ||
page_index | Int | Long | Index of the page being transitioned to. | |
screen_dismissed | screen_id | Int | Long | |
page_count | Int | Long | Stories only. | |
pages_viewed | Int | Long | Stories only, pages viewed before the story was dismissed. | |
opener_tapped | screen_id | Int | Long | |
button_tapped | uri | String | String | This will be the Unflow action (e.g. "unflow://action") or your custom URI. |
rating_response | screen_id | Int | Long | |
rating | Int | Long | ||
page_appear | screen_id | Int | Long | |
page_id | Int | Long | ||
page_index | Int | Long | ||
total_duration | Double | Long | Total duration of the page in seconds. | |
page_disappear | screen_id | Int | Long | |
page_id | Int | Long | ||
page_index | Int | Long | ||
total_duration | Double | Long | Total duration of the page in seconds. | |
remaining_duration | Double | Long | Remaining duration when the page was dismissed, in seconds. | |
question_answered | screen_id | Int | Long | |
block_id | Int | Long | ||
selections | [String] | List<String> | Identifiers of the selections. | |
selection_strings | [String] | List<String> | Titles of the options selected ( 1.12.0 onwards ) | |
analytics_id | String | String | Optional analytics ID if provided on the dashboard. |