Skip to main content

User Identification

Identify users to track their activity:
// Identify user with ID only
Zixflow.instance().identify(userId = "user@example.com")

// Identify user with additional attributes
Zixflow.instance().identify(
    userId = "user@example.com",
    traits = mapOf(
        "first_name" to "John",
        "last_name" to "Doe",
        "email" to "user@example.com",
        "plan" to "premium"
    )
)
Java:
// Identify user with ID only
Zixflow.instance().identify("user@example.com");

// Identify user with attributes
Map<String, Object> traits = new HashMap<>();
traits.put("first_name", "John");
traits.put("last_name", "Doe");
traits.put("email", "user@example.com");
Zixflow.instance().identify("user@example.com", traits);
Events tracked before identify() are attributed to an anonymous profile. After you identify a user, that anonymous activity is associated with the identified person.
val anonymousId = Zixflow.instance().anonymousId
val isIdentified = Zixflow.instance().isUserIdentified

Event Tracking

Track custom events:
// Simple event
Zixflow.instance().track(name = "Button Clicked")

// Event with properties
Zixflow.instance().track(
    name = "Product Purchased",
    properties = mapOf(
        "product_id" to "123",
        "product_name" to "Widget",
        "price" to 29.99,
        "currency" to "USD"
    )
)
Java:
// Simple event
Zixflow.instance().track("Button Clicked");

// Event with properties
Map<String, Object> properties = new HashMap<>();
properties.put("product_id", "123");
properties.put("product_name", "Widget");
properties.put("price", 29.99);
Zixflow.instance().track("Product Purchased", properties);

Screen Tracking

Track screen views:
// Manual screen tracking
Zixflow.instance().screen(
    title = "Product Detail",
    properties = mapOf(
        "product_id" to "123",
        "category" to "Electronics"
    )
)

// Enable automatic activity screen tracking (in configuration)
val config = ZixflowConfigBuilder(this, "YOUR_API_KEY")
    .autoTrackActivityScreens(true)
    .build()
Java:
// Manual screen tracking
Map<String, Object> properties = new HashMap<>();
properties.put("product_id", "123");
properties.put("category", "Electronics");
Zixflow.instance().screen("Product Detail", properties);
Screen views also drive in-app message route targeting. Call screen() when users navigate if your campaigns target specific screens.

Profile Attributes

Set user profile attributes:
// Set profile attributes
Zixflow.instance().setProfileAttributes(
    mapOf(
        "age" to 30,
        "gender" to "male",
        "subscription_status" to "active"
    )
)
Java:
Map<String, Object> attributes = new HashMap<>();
attributes.put("age", 30);
attributes.put("gender", "male");
Zixflow.instance().setProfileAttributes(attributes);
If no user is identified yet, profile attributes update the anonymous profile.

Device Attributes

Set device attributes:
// Set device-specific attributes
Zixflow.instance().setDeviceAttributes(
    mapOf(
        "app_version" to "2.1.0",
        "custom_device_flag" to true
    )
)
With autoTrackDeviceAttributes(true) (the default), the SDK also collects attributes such as device_os, device_model, device_manufacturer, app_version, zixflow_sdk_version, device_locale, and push_enabled.

Device Token

The push module registers FCM tokens automatically. You can also manage tokens manually:
// Register a token manually (rarely needed with ModuleMessagingPushFCM)
Zixflow.instance().registerDeviceToken("fcm-device-token")

// Read the currently registered token
val deviceToken = Zixflow.instance().registeredDeviceToken
if (deviceToken != null) {
    println("Device token: $deviceToken")
} else {
    println("Device token not yet registered")
}

// Delete the registered device token
Zixflow.instance().deleteDeviceToken()

User Logout

Clear user identification when they log out:
// Clear identified user
Zixflow.instance().clearIdentify()
Java:
Zixflow.instance().clearIdentify();
clearIdentify() resets analytics state, generates a new anonymousId, and deletes the registered device token.