Spectacle JS

Group

Associating users with groups in Spectacle

The group function in Spectacle allows you to associate a user with a specific group, such as a company, organization or account.

Understanding group tracking

Group calls help you analyze user data in the context of their organization. There are two important IDs in a Group call:

  • groupId: identifies the specific group or company
  • userId (or anonymousId): identifies the individual user

A user can belong to one group at a time. Once a user is in a group, any subsequent calls to group will override the user's group.

spectacle.group(groupId, [traits])

Parameters

  • groupId (String, required): A unique identifier for the group in your database
  • traits (Object, optional): Properties that describe the group, such as name, industry, or plan

Example usage

Basic group call associating the current user with a group:

spectacle.group('company_123', {
  name: 'Acme Inc.',
  plan: 'enterprise',
})

Special traits for group

Spectacle recognizes certain special traits in the group traits:

TraitTypeDescription
nameStringThe name of the group/company
descriptionStringA description of the group/company
websiteStringThe website of the company, either as full url 'https://coolcompany.com' or domain 'www.coolcompany.com'
phoneStringA phone number for the group/company
employeesStringA description of the group/company
linkedInUrlStringThe LinkedIn url for the group/company
emailStringAn email address for the company
industryStringThe industry the company is active in
planStringThe subscription plan of the company

You can also include any custom traits that are relevant to your business:

spectacle.group('company_123', {
  name: 'Acme Inc.',
  industry: 'Technology',
  employees: 329,
  plan: 'enterprise',
  annualRevenue: '5000000',
  region: 'EMEA',
  customerSince: '2022-01-15',
})

When to use group

Group calls are most valuable in these scenarios:

  1. When onboarding a new user who belongs to an organization
  2. When a user's group membership changes
  3. When a group's properties change (e.g., upgrading to a new plan)

Combining group tracking with identify calls can link customer journeys for several users together.

Previous
track()