Quick Start — Android SDK
Prerequisites
- Installation complete
- Your CDP API key
Step 1 — Initialize in Application
class MyApp : Application() {
override fun onCreate() {
super.onCreate()
val config = OpenCDPConfig(
cdpApiKey = "YOUR_CDP_API_KEY",
debug = true,
autoTrackScreens = true,
trackApplicationLifecycleEvents = true,
)
OpenCDP.initialize(this, config)
}
}
Step 2 — Identify a user
OpenCDP.identify(
identifier = "user_123",
properties = mapOf(
"email" to "[email protected]",
"plan" to "pro",
),
)
identifier must not be an email address.
Step 3 — Track an event
OpenCDP.track(
eventName = "purchase",
properties = mapOf("amount" to 99.9),
)
Step 4 — Track a screen view
With autoTrackScreens = true, Activity resumes are tracked automatically (title if set, else class simple name). For readable catalog names — especially Fragments / Compose / Navigation — call explicitly:
OpenCDP.trackScreenView(
title = "/product-details",
properties = mapOf("sku" to "ABC-001"),
)
See Screen tracking.
Step 5 — Register device token (push)
In your FirebaseMessagingService:
override fun onNewToken(token: String) {
OpenCDP.registerDeviceToken(token)
}
Step 6 — Test push from console
Use the same person ID (user_123) in Test push notification → Test by User ID.
See Identity and devices.
Gateway request timeout
cdpRequestTimeoutMs is in milliseconds. The built-in default is 30000 (30 seconds). The SDK clamps any value below 5000 up to 5 seconds, and any value above 120000 down to 120 seconds.
The timeout is how long the SDK waits for one gateway host to answer a single request. On a timeout, a network error, or a non-success status, the SDK tries the next host immediately:
https://api.opencdp.io/gateway/data-gatewayhttps://api.open-cdp.com/gateway/data-gatewayhttps://api.open-cdp.xyz/gateway/data-gateway
Leave cdpRequestTimeoutMs unset to keep the 30 second default. To wait 20 seconds on each host, pass 20000:
val config = OpenCDPConfig(
cdpApiKey = "YOUR_CDP_API_KEY",
cdpRequestTimeoutMs = 20_000, // 20 seconds
)
Verify it worked
With debug = true, Logcat shows successful identify/track POSTs.