Group

View as Markdown

The group call provides a way to associate individual users with groups, such as a company, organization, team, association, or initiative. A user who has been identified can be associated with several groups.

It also provides the ability to store custom traits related to that group, such as organization name and industry sector, or account type and annual revenue.

When to use the group call

For best results, it is recommended to make a group call in the following scenarios:

  • When a new user signs up or onboards to your website or application.
  • Whenever there are changes in group-specific traits (e.g., industry, employee count).
  • In situations where users can dynamically switch between different groups during their session.

How to make a group call

To make a group call, you can use a Krenalis SDK.

krenalis.group('group-890', {
    name: 'AcmeTech',
    industry: 'Technology',
    employeeCount: 100
});

Refer to the JavaScript SDK for more details.

analytics.group(
    user_id="user-123",
    group_id="group-890",
    traits={
        "name": "AcmeTech",
        "industry": "Technology",
        "employeeCount": 100,
    },
)

Refer to the Python SDK for more details.

client.Enqueue(analytics.Group{
    UserId: "user-123",
    GroupId: "group-890",
    Traits: map[string]any{
        "name":          "AcmeTech",
        "industry":      "Technology",
        "employeeCount": 100,
    },
})

Refer to the Go SDK for more details.

analytics.group({
    userId: 'user-123',
    groupId: 'group-890',
    traits: {
        name: 'AcmeTech',
        industry: 'Technology',
        employeeCount: 100
    }
});

Refer to the Node.js SDK for more details.

analytics.enqueue(GroupMessage.builder("group-890")
    .userId("user-123")
    .traits(new com.krenalis.analytics.messages.Properties()
        .putValue("name", "AcmeTech")
        .putValue("industry", "Technology")
        .putValue("employeeCount", 100))
);

Refer to the Java SDK for more details.

Analytics.Client.Group("user-123", "group-890", new Properties {
    { "name", "AcmeTech" },
    { "industry", "Technology" },
    { "employeeCount", 100 }
});

Refer to the .NET SDK for more details.

analytics.group(
    userId = "user-123",
    groupId = "group-890",
    traits = buildJsonObject {
        put("name", "AcmeTech")
        put("industry", "Technology")
        put("employeeCount", 100)
    }
)

Refer to the Android SDK for more details. You can also use the Java language with the Android SDK.

The following is an example of how the previous group call would appear in Krenalis once received and processed:

{
  "connectionId": 129402661,
  "anonymousId": "f8d886bf-e1a6-484c-9ded-ac789ec4146b",
  "channel": "browser",
  "context": {
    "ip": "172.16.254.1",
    "userAgent": "Mozilla/5.0 (Macintosh) Chrome/138 Safari/537.36"
  },
  "messageId": "0a2ef1d3-ebad-41b2-9c8a-7b58d8e1a8f9",
  "receivedAt": "2025-10-13T09:42:51.477Z",
  "sentAt": "2025-10-13T09:42:51.210Z",
  "timestamp": "2025-10-13T09:42:51.210Z",
  "traits": {
    "name": "AcmeTech",
    "industry": "Technology",
    "employeeCount": 100
  },
  "type": "group",
  "userId": "user-123",
  "groupId": "group-890"
}

As you can see, there is much more information than what is provided in SDK examples. This is because both the SDK used to make the call and Krenalis enrich the information by extracting it from the device where the event occurs. Refer to the SDK documentation for more details.

Traits

As seen earlier, traits are pieces of information about the event's group that you wish to store along with the event. You can include whatever information you need.

They are accessible in Krenalis within a property of the event called traits as a JSON value.

Prefilled traits

Krenalis doesn't automatically forward a group's traits to a destination. Instead, the control lies in your hands to choose and specify the traits you want to send when configuring the mapping.

However, when you set up a mapping, Krenalis automatically fills in the mapping expressions with the following traits when applicable:

Trait JSON Type Description
address Object Address. Can include the following String fields "street", "city", "state", "postalCode", and "country".
avatar String URL of the avatar image.
createdAt String Date of account creation in the ISO 8601 format.
description String Description of the group.
email String Email address of the group.
employees String Number of employees, commonly referred to when the group is a company.
id String Unique identifier of the group.
industry String industry where the group belongs or where the user works.
name String Name of the group.
phone String Phone number.
website String URL of the group's website.
plan String Plan that the group is enrolled in.