Learn about the identify API call in the Android (Kotlin) and iOS (Swift) SDKs.
analytics.identify(
userId = "<userId>",
traits = buildJsonObject {
put("key", "value")
},
options = RudderOption(),
)
The corresponding Java snippet is shown below:
HashMap<String, Object> traits = new HashMap<>();
traits.put("key", "value");
analytics.identify("<userId>", traits, new RudderOption());
// 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>"),
),
),
)
analytics.identify(
userId: "User 1",
traits: [
"key-1": "value-1"
],
options: RudderOption()
)

Make sure to include the import RudderStackAnalytics statement before making the call.
The corresponding Objective-C snippet is shown below:
[analytics identify:@"User 1"
traits:@{
@"key-1": @"value-1"
}
options:[[RSSOptionBuilder new] build]];

RSSOptionBuilder is an Objective-C–only helper class. It uses the builder pattern to create an RSSOption instance and lets you set custom context, configure integrations, and attach external IDs in a structured way.
// Identify event with userId
analytics.identify(userId: "User 1")
// Identify event with traits
analytics.identify(
traits: [
"key-1": "value-1"
]
)
// Identify event with userId and traits
analytics.identify(
userId: "User 1",
traits: [
"key-1": "value-1"
]
)
// Identify event with userId and options
analytics.identify(
userId: "User 1",
options: RudderOption(
integrations: [
"Amplitude": true,
"INTERCOM": [
"lookup": "phone"
]
],
customContext: [
"key-1": "value-1"
],
externalIds: [
ExternalId(type: "brazeExternalId", id: "value1234")
]
)
)
// Identify event with traits and options
analytics.identify(
traits: [
"key-1": "value-1"
],
options: RudderOption(
integrations: [
"Amplitude": true,
"INTERCOM": [
"lookup": "phone"
]
],
customContext: [
"key-1": "value-1"
],
externalIds: [
ExternalId(type: "brazeExternalId", id: "value1234")
]
)
)
The corresponding Objective-C snippet is shown below:
// Identify event with userId
[analytics identify:@"User 1"];
// Identify event with traits
[analytics identifyWithTraits:@{
@"key-1": @"value-1"
}];
// Identify event with userId and traits
[analytics identify:@"User 1"
traits:@{
@"key-1": @"value-1"
}];
// Identify event with userId and options
RSSOptionBuilder *optionBuilder = [[RSSOptionBuilder alloc] init];
[optionBuilder setCustomContext:@{
@"key-1": @"value-1"
}];
[optionBuilder setIntegrations:@{
@"Amplitude": @YES,
@"INTERCOM": @{
@"lookup": @"phone"
}
}];
[optionBuilder setExternalIds:@[
[[RSSExternalId alloc] initWithType:@"brazeExternalId" id:@"value1234"]
]];
[analytics identify:@"User 1"
options:[optionBuilder build]];
// Identify event with traits and options
[analytics identifyWithTraits:@{
@"key-1": @"value-1"
}
options:[optionBuilder build]];