Screen tracking — Android
OpenCDP can auto-track Activity resumes and accepts explicit trackScreenView calls. Screen names feed the workspace screen catalog used by in-app Include / Exclude page rules.
Auto-track
With autoTrackScreens = true, each Activity.onResume records a screen view:
- Non-blank Activity title (if set), else
- Activity simple class name (e.g.
MainActivity)
Empty, anonymous, or technical names are skipped.
val config = OpenCDPConfig(
cdpApiKey = "YOUR_CDP_API_KEY",
autoTrackScreens = true,
)
OpenCDP.initialize(this, config)
Prefer readable names (recommended)
Call trackScreenView yourself with a stable id whenever navigation changes — for example with Jetpack Navigation (OpenCDP does not depend on Navigation Component):
navController.addOnDestinationChangedListener { _, destination, _ ->
val name = destination.route ?: destination.label?.toString() ?: return@addOnDestinationChangedListener
OpenCDP.trackScreenView(title = name)
}
Or from Compose / Fragments:
OpenCDP.trackScreenView(
title = "/checkout/payment",
properties = mapOf("step" to 2),
)
Recommended shapes: /profile, Home, checkout/payment. Avoid framework dumps and empty strings.
Manual-only mode
Set autoTrackScreens = false and call trackScreenView on every screen you care about for page rules.