Group API in Mobile SDKs

Learn about the group API call in the Android (Kotlin) and iOS (Swift) SDKs.

This guide explains how to use the group API in the Android (Kotlin) and iOS (Swift) SDKs.

Overview

The RudderStack Android (Kotlin) and iOS (Swift) SDKs provide a group API that lets you link an identified user with a group like a company, organization, or an account. You can also record any custom traits associated with that group like the company name, number of employees, etc.

info
You can link an identified user to multiple groups.

Android (Kotlin)

The group method definition in the Android (Kotlin) SDK is as follows:

Method signature

The below table describes the group method signature in detail:

FieldData typeDescription
groupIdStringThe group’s unique identifier in your database.
traitsTraitsContains traits associated with the group. They are added in the root level of the event.

Note that:

  • RudderStack does not store any group traits.
  • The traits type in Java is Map<String, Object>.
optionsRudderOptionAdditional event options.

Example

A sample group event sent from the Android (Kotlin) SDK is shown below:

iOS (Swift)

The group method definition in the iOS (Swift) SDK is as follows:

Method signature

The below table describes the group method signature in detail:

FieldData typeDescription
groupIdStringThe group’s unique identifier in your database.
traitsTraitsContains traits associated with the group. They are added in the root level of the event.
optionsRudderOptionAdditional event options.

Example

A sample group event sent from the iOS (Swift) SDK is shown below:


Questions? Contact us by Email or on Slack