Screen Events
Screen events record which screens a contact opens, so you can segment contacts and start automations by screen name. General rules for events: Sending Events.
Requirements
- A successful
ping()in this installation, see Contacts.
UserCom.initialize does not track screens automatically. Call trackScreen(name) for every screen you want to see in the panel.
Setup
Call trackScreen when the screen is shown, with a name you choose. Call it from the place where your app knows that a screen became visible, for example onResume of an activity or fragment, or a destination listener of your navigation library.
- Kotlin
- Java
override fun onResume() {
super.onResume()
UserCom.default?.trackScreen("Home")
}
@Override
protected void onResume() {
super.onResume();
UserCom sdk = UserCom.getDefault();
if (sdk != null) sdk.trackScreen("Home");
}
The screen event appears on the contact's timeline with the screen name you expect.
Methods
trackScreen
Queues a screen event for the current contact.
Optional unless marked required
- name
- The screen name, up to 128 characters. Segments and automations match on this value.
- callback
- Called with the result on the main thread. See Callback thread.
Returns nothing. Without a contact (no successful ping yet), the callback gets NotIdentified and the event is not queued. An empty name or a name over 128 characters ends with InvalidName without a request.
UserCom.default?.trackScreen("Checkout")
Automatic tracking with the deprecated Builder
The deprecated UserCom.Builder(...).trackAllActivities(true) still sends a screen event every time an activity starts, named after the activity class or its @ScreenName annotation. It stays until 3.0. Fragments and Compose destinations are not tracked this way, so trackScreen(name) is the recommended way.
The @TrackArguments annotation has no effect: screen events do not carry the extras of the intent, which could contain personal data.
Common errors
| Symptom | Cause | Fix |
|---|---|---|
| No screen events at all | Screens are not tracked automatically. | Add trackScreen(name) calls. |
| The first screen at launch is missing | It was tracked before the first successful ping. | Track it after ping() completes, or accept that the first screen of a fresh install is not recorded. |
Callback reports InvalidName | The screen name is empty or longer than 128 characters. | Use a name of 1 to 128 characters. |
| An automation does not start | The screen name in the automation differs from the name sent. | Use the exact same name, including letter case. |