Learn about the alias API call in the Android (Kotlin) and iOS (Swift) SDKs.
analytics.alias(
newId = "<newId>",
previousId = "<previousId>",
options = RudderOption()
)
The corresponding Java snippet is shown below:
analytics.alias("<newId>", "<previousId>", new RudderOption());
// Alias event with newId
analytics.alias(newId = "<newId>")
// Alias event with newId and previousId
analytics.alias(
newId = "<newId>",
previousId = "<previousId>"
)
// Alias event with newId and options
analytics.alias(
newId = "<newId>",
options = RudderOption(
customContext = buildJsonObject {
put("key", "value")
},
integrations = buildJsonObject {
put("Amplitude", true)
put("INTERCOM", buildJsonObject {
put("lookup", "phone")
})
},
externalIds = listOf(
ExternalId(type = "<id_type>", id = "<value>")
)
)
)
analytics.alias(
newId: "<newId>",
previousId: "<previousId>",
options: RudderOption()
)

Make sure to include the import RudderStackAnalytics statement before making the call.
The corresponding Objective-C snippet is shown below:
[analytics alias:@"<newId>" previousId:@"<previousId>" 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.
// Alias event with newId
analytics.alias(newId: "Alias ID 1")
// Alias event with newId and previousId
analytics.alias(
newId: "Alias ID 1",
previousId: "Explicit Previous User ID 1"
)
// Alias event with newId and options
analytics.alias(
newId: "Alias ID 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:
// Alias event with newId
[analytics alias:@"Alias ID 1"];
// Alias event with newId and previousId
[analytics alias:@"Alias ID 1" previousId:@"Explicit Previous User ID 1"];
// Alias event with newId 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 alias:@"Alias ID 1" options:[optionBuilder build]];