Group API in Kotlin SDK Alpha

Learn about the group API call in Kotlin SDK.

This guide explains how to use the group API in Kotlin SDK.

Overview

The Kotlin SDK provides 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.

Method definition

The group method definition is as follows:

The below table describes the group method signature in detail:

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

Note: RudderStack does not store any group traits.
optionsRudderOptionAdditional event options.

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

analytics.group(
    groupId = "5e8a78ba9d32d3b1898a6247",
    traits = buildJsonObject {
        put("name", "RudderStack")
    },
    options = RudderOption(
        customContext = buildJsonObject {
            put("plan", "Basic")
        },
        integrations = buildJsonObject {
            put("Amplitude", true)
            put("INTERCOM", buildJsonObject {
                put("lookup", "phone")
            })
        },
        externalIds = listOf(
            ExternalId(type = "brazeExternalId", id = "value1234"),
        )
    )
)

Questions? Contact us by email or on Slack