Learn about the track API call in the Android (Kotlin) and iOS (Swift) SDKs.
analytics.track(
name = "Product Added",
properties = buildJsonObject {
put("key", "value")
},
options = RudderOption()
)
The corresponding Java snippet is shown below:
HashMap<String, Object> properties = new HashMap<>();
properties.put("key", "value");
analytics.track("Product Added", properties, new RudderOption());
// Track event with event name
analytics.track(name = "Product Added")
// Track event with event name and properties
analytics.track(
name = "Product Added",
properties = buildJsonObject {
put("key-1", "value-1")
},
)
// Track event with event name and options
analytics.track(
name = "Product Added",
options = RudderOption(
customContext = buildJsonObject {
put("key-1", "value-1")
},
integrations = buildJsonObject {
put("Amplitude", true)
put("INTERCOM", buildJsonObject {
put("lookup", "phone")
})
},
externalIds = listOf(
ExternalId(type = "brazeExternalId", id = "value1234"),
),
),
)
analytics.track(
name: "Product Added",
properties: [
"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 track:@"Product Added"
properties:@{
@"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.
// Track event with event name
analytics.track(name: "Product Added")
// Track event with event name and properties
analytics.track(
name: "Product Added",
properties: [
"key-1": "value-1"
]
)
// Track event with event name and options
analytics.track(
name: "Product Added",
properties: [
"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:
// Track event with event name
[analytics track:@"Product Added"];
// Track event with event name and properties
[analytics track:@"Product Added"
properties:@{
@"key-1": @"value-1"
}];
// Track event with event name 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 track:@"Product Added"
properties:@{
@"key-1": @"value-1"
}
options:[optionBuilder build]];