On this page
Add an account ID or a custom event when it helps explain a journey. Use an internal ID for identification and send an outcome event only after your app confirms the outcome.
Applies to native Android SDK 1.2.0. Initialize the SDK before using these methods.
Identify a user
Use a stable identifier from your own system and a small set of useful attributes:
import io.cux.analytics_sdk.CuxAnalytics
CuxAnalytics.setUserProperties(
userId = "account-123",
params = mapOf("plan" to "pro")
)
Identification is optional for basic tracking. Call this after your app knows which account is active. Do not use an email address or send a name, address or payment detail as an attribute.
Test logout and switching accounts on the same device. Do not assume stop/resume clears identity. Confirm the supported identity-clearing behavior for your installed SDK before using it on shared devices.
Track a custom event
Use trackEvent() when all parameter values are strings:
CuxAnalytics.trackEvent(
eventName = "checkout_completed",
params = mapOf("currency" to "USD", "plan" to "pro"),
label = "subscription"
)
Call this from your confirmed-success handler, not from the button's tap callback. Keep the event name stable and avoid sending the same event from multiple callbacks.
Preserve numbers and booleans
Use trackEventTyped() for simple typed values:
CuxAnalytics.trackEventTyped(
name = "checkout_completed",
params = mapOf(
"value" to 99.0,
"currency" to "USD",
"returning" to true
),
label = "subscription"
)
Strings, supported numeric values and booleans keep their types. Do not send nested objects, lists or null values. If any input is invalid, the SDK rejects the whole event before enqueueing it.
Typed event limits
These limits apply to trackEventTyped() in 1.2.0, not automatically to every mobile event or identity API.
| Input | Rule |
|---|---|
| Event name | Required, not blank, at most 100 characters |
| Label | Optional; at most 100 characters when provided |
| Parameters | A non-null flat map with at most 50 entries |
| Parameter key | A non-empty string, at most 100 characters |
| String value | At most 100 characters |
| Boolean value | true or false |
| Numeric value | Kotlin Byte, Short, Int, bounded Long, or finite bounded Float/Double |
| Unsupported values | null, collections, objects and other scalar classes are rejected |
Keys must not contain . or start with $. The keys __proto__, prototype and constructor are rejected.
For Long, the allowed range is -9,007,199,254,740,991 to 9,007,199,254,740,991. The absolute value of Float and Double must not exceed that boundary. NaN and infinity are rejected.
Keep personal data out of events
Screenshot masks do not filter event names, labels or parameters. Review the values in your code and send only what you need to interpret the outcome.
Verify the result
Complete the action once in a test account, then check the event in CUX. Inspect each parameter and check that typed numbers and booleans retain the expected types where your data view exposes them.
Repeat without completing the action and check that the success event does not appear. Test repeated success callbacks to catch duplicates.
If a typed event is missing, compare every field with the limits above. Do not expect a partial event when one field fails validation. See Android troubleshooting.