Identify API in Kotlin SDK Alpha

Learn about the identify API call in Kotlin SDK.

This guide explains how to use the identify API in Kotlin SDK.

Overview

The Kotlin SDK provides an identify API that lets you identify a user and associate them to their actions. It also lets you record any traits about them like their name, email, etc.

info
Once you make the identify call, the SDK persists the user information and passes it to the subsequent calls.

Method definition

The identify method definition is as follows:

The below table describes the identify method signature in detail:

FieldData typeDescription
userIdStringUnique user identifier. When provided, RudderStack prefers this field over anonymousId while sending data to the destinations.
traitsTraitsContains the user traits or the properties associated with userId such as email, address, etc. See Identify traits for more information.

Note: RudderStack stores the traits as context.traits in the final event object.
optionsRudderOptionAdditional event options.

A sample identify event sent from the Kotlin SDK is shown below:

analytics.identify(
    userId = "1hKOmRA4GRlm",
    traits = buildJsonObject {
        put("city", "New Orleans")
    },
    options = RudderOption(
        customContext = buildJsonObject {
            put("key", "value")
        },
        integrations = buildJsonObject {
            put("Amplitude", true)
            put("INTERCOM", buildJsonObject {
                put("lookup", "phone")
            })
        },
        externalIds = listOf(
            ExternalId(type = "brazeExternalId", id = "value1234"),
        ),
    ),
)

Questions? Contact us by email or on Slack