Screen tracking
UpdatedScreen views are events that record the pages that your audience visits in your app. They have a type
property set to screen
, and a name
representing the title of the screen or page that a person visited in your app.
Screen view events let you trigger campaignsA series of actions that you perform for each person who matches criteria. Campaigns typically send people a series of messages, but you can also use campaigns to send webhooks, update attributes, etc. or add people to segmentsA group of people who match a series of conditions. People enter and exit the segment automatically when they match or stop matching conditions. based on the parts of your app your audience uses. Screen view events also update your audience’s “Last Visited” attribute, which can help you track how recently people used your app.
Enable automatic screen tracking
When you enable automatic screen tracking, the SDK sends an event every time a person visits a screen in your app. You can turn on automatic screen tracking by appending autoTrackActivityScreens(true)
to CustomerIOBuilder
.
When automatically tracking screen events, we capture the name of the screen with the following priority from highest to lowest:
- We check if the current
Activity
has alabel
in the manifest file. If it does, the SDK will use the value forlabel
. - We get the class name of the
Activity
and use that value.
The SDK will take whatever value it receives and will strip the word Activity
from it. Example: If you have an Activity
with the manifest label
or class name ProfileActivity
, the SDK will track the screen view with the name Profile
.
val builder = CustomerIOBuilder(
appContext = this,
cdpApiKey = "your-cdp-api-key",
)
builder.autoTrackActivityScreens(true)
builder.build()
If you want to send more data with screen events, or you don’t want to send events for every individual screen that people view in your app, you can send screen events manually.
Send your own screen events
Screen events use the .screen
method. Like other events, you can add a map of properties
object containing additional information about the screen
event or the currently-identified person.
CustomerIO.instance().screen("baseballDailyScores", buildJsonObject {
put("prevScreen", "home")
put("secondsInApp", 120)
});
CustomerIO.instance().screen(
name = "baseballDailyScores",
properties = mapOf("prevScreen" to "homescreen", "secondsInApp" to 120)
)