Skip to content

Track events & screens

Triggers set in the Mobile app tab react to three things: an event, a screen and app launch. Your app reports the first two with track and screen. App launch needs no call.

Events and screen names stay on the device. track and screen exist to start surveys, not to collect analytics, and nothing they receive is uploaded.

Call track where something happens that a survey could follow.

Responsly.shared.track("purchase_completed", properties: ["value": 49.9, "category": "books"])

Each call does two things:

  1. Adds one to the count of that event name on this device.
  2. Checks the event triggers of every survey in the configuration.

An event trigger matches when all of these are true:

Trigger settingRule
Event nameEqual to the name you pass. Case-sensitive: Purchase_Completed does not match purchase_completed.
From occurrence no.The count of this event, including the current call, has reached the number. With 3, the third call and every later one match.
Property conditionsEvery condition is true for the properties of this call.

Things to know:

  • The count is kept per install and survives restarts. It goes up on every call, whether or not the conditions match. reset clears it.
  • Property values are strings, numbers, booleans or dates, the same types as user attributes. They are used for this one check and are not stored.
  • A condition on a property you did not pass is false for “equals”, “contains” and the comparisons, and true for “does not equal”, “does not contain” and “does not exist”. The rules are in Targeting.
  • If an event has no properties, pass an empty map.

Call screen whenever the visible screen changes.

Responsly.shared.screen("Checkout")

Each call sets the current screen and checks screen triggers. A screen trigger matches when its name equals the name you pass (case-sensitive).

Report every screen, not only the ones that have a survey. When a survey has a delay, the SDK shows it only if the user is still on the screen that triggered it. It knows the user left because you reported the next screen.

The app launch trigger needs no call. It is checked once per app process, as soon as the configuration is available after initialize. Returning from the background is not a launch.

There is no automatic tracking on iOS. Report the screen where it appears.

UIKit
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
Responsly.shared.screen("Checkout")
}
SwiftUI
CheckoutView()
.onAppear { Responsly.shared.screen("Checkout") }
  • track and screen are safe before initialize and from any thread.
  • Calls made before the configuration has been downloaded are queued and checked, in order, once it arrives. The queue holds 50 calls; older ones are dropped. Event counts go up immediately either way.
  • One call can match several surveys. The SDK shows the first eligible one and reports the others to surveyNotShown. Only one survey is on screen at a time.
  • A matching trigger is the start, not the end: audience, frequency, schedule and sampling are checked next. See Targeting.

If the app already calls an analytics SDK, send the same events to Responsly from the same helper. See Integrations.