group()

The group() method associates a user with a company, organisation, or account. This is useful for B2B applications where you need to attribute events to a specific organisation.

Syntax

iOS (Swift)

Datafly.shared.group(groupId: String, traits: [String: Any]? = nil)

Android (Kotlin)

Datafly.group(groupId: String, traits: Map<String, Any>? = null)

React Native / Cordova

Datafly.group(groupId, traits?)

Flutter

await Datafly.group(groupId, traits: {...})

Parameters

ParameterTypeRequiredDescription
groupIdStringYesUnique identifier for the company/organisation
traitsDictionary/MapNoKey-value pairs describing the group

Usage

Datafly.shared.group(groupId: "company-456", traits: [
    "name": "Acme Corp",
    "industry": "Technology",
    "plan": "enterprise",
    "employees": 250,
])

Once called, the groupId is included in all subsequent events until reset() is called.

Common traits

TraitTypeDescription
nameStringCompany name
industryStringIndustry vertical
planStringSubscription plan
employeesIntNumber of employees
websiteStringCompany website URL
created_atStringISO 8601 date the account was created