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.
Once you make the identify call, the SDK persists the user information and passes it to the subsequent calls.
// Identify event with userId
analytics.identify(userId="<userId>")// Identify event with traits
analytics.identify(traits=buildJsonObject{put("key","value")},)// Identify event with userId and traits
analytics.identify(userId="<userId>",traits=buildJsonObject{put("key","value")},)// Identify event with userId and options
analytics.identify(userId="<userId>",options=RudderOption(customContext=buildJsonObject{put("key","value")},integrations=buildJsonObject{put("Amplitude",true)put("INTERCOM",buildJsonObject{put("lookup","field")})},externalIds=listOf(ExternalId(type="<id_type>",id="<value>"),),),)// Identify event with traits and options
analytics.identify(traits=buildJsonObject{put("key","value")},options=RudderOption(customContext=buildJsonObject{put("key","value")},integrations=buildJsonObject{put("Amplitude",true)put("INTERCOM",buildJsonObject{put("lookup","field")})},externalIds=listOf(ExternalId(type="<id_type>",id="<value>"),),),)
The below table describes the identify method signature in detail:
Field
Data type
Description
userId
String
Unique user identifier. When provided, RudderStack prefers this field over anonymousId while sending data to the destinations.
traits
Traits
Contains 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.
options
RudderOption
Additional event options.
A sample identify event sent from the Kotlin SDK is shown below:
This site uses cookies to improve your experience while you navigate through the website. Out of
these
cookies, the cookies that are categorized as necessary are stored on your browser as they are as
essential
for the working of basic functionalities of the website. We also use third-party cookies that
help
us
analyze and understand how you use this website. These cookies will be stored in your browser
only
with
your
consent. You also have the option to opt-out of these cookies. But opting out of some of these
cookies
may
have an effect on your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. This
category only includes cookies that ensures basic functionalities and security
features of the website. These cookies do not store any personal information.
This site uses cookies to improve your experience. If you want to
learn more about cookies and why we use them, visit our cookie
policy. We'll assume you're ok with this, but you can opt-out if you wish Cookie Settings.