Groups

Account-level analytics: assign users to companies and workspaces.

Groups model B2B relationships: companies, workspaces, teams. You assign the current user to groups, attribute events to the active group, and optionally set persistent properties on the group itself.

The browser SDK uses the stored identity automatically. The server SDKs take the distinctId / distinct_id first.

Core concepts

TermMeaning
Group keyThe type of group: company, team, active_team.
Group IDOne instance: acme-inc, team-uuid-123.
MembershipWhich group IDs the user belongs to, per key.
Active contextThe group the user is currently working in; drives event attribution.
Group profilePersistent properties on a (key, id) pair.

Membership

  • add_group adds a permanent membership (the user joins a group). Idempotent.
  • set_group switches the active context for a key. Events fired after the switch attribute to the new group.
await Trodo.add_group('company', 'acme-inc');     // permanent
await Trodo.set_group('active_team', 'team-b-id'); // active context
await Trodo.remove_group('team', 'design');
await trodo.add_group('user-42', 'company', 'acme-inc');
await trodo.set_group('user-42', 'active_team', 'team-b-id');
await trodo.remove_group('user-42', 'team', 'design');
trodo.add_group('user-42', 'company', 'acme-inc')
trodo.set_group('user-42', 'active_team', 'team-b-id')
trodo.remove_group('user-42', 'team', 'design')

Only events fired after a group call are attributed; there's no historical rewrite.

Group profile

get_group(key, id) returns a handle for setting properties on the group entity (not the user, and not event attribution):

const team = Trodo.get_group('team', 'team-a-id');
await team.set({ name: 'Engineering', plan: 'enterprise', seat_count: 50 });
await team.increment('seat_count', 5);
await team.union('tags', ['b2b']);
const team = trodo.forUser('user-42').get_group('team', 'team-a-id');
await team.set({ name: 'Engineering', plan: 'enterprise', seat_count: 50 });
await team.increment('seat_count', 5);
team = trodo.for_user('user-42').get_group('team', 'team-a-id')
team.set({'name': 'Engineering', 'plan': 'enterprise', 'seat_count': 50})
team.increment('seat_count', 5)

The group handle supports set, set_once, increment, append, union, remove, unset, and delete.

Multi-team pattern

Most B2B apps have users in several teams permanently but working in one at a time. Use two keys:

KeyMethodPurpose
teamadd_groupall teams the user permanently belongs to
active_teamset_groupthe current workspace, drives event attribution

People vs. Groups

PeopleGroups
Describesthe end useran org, team, or workspace
BrowserTrodo.people.*Trodo.set_group / add_group / get_group
Serveruser.people.*trodo.{set_group, add_group, get_group}(distinctId, …)

Next

  • People for user-level properties
  • Identity for cross-device group membership

On this page