The group() method associates the currently identified user with a company and optionally updates the company’s attributes. Call this method once on any page where the user is working with a specific company. When the user switches to a different company, call usertour.group(newGroupId) again to update the association.

When you provide attributes, they will be merged with the company’s existing attributes in Usertour. Attributes not included in the call will retain their current values.

Parameters

groupId
string
required

The unique identifier for the company in your system.

attributes
object

Company attributes to update. See Attributes for details. These attributes can be used in flow content and conditions to personalize the user experience.

options.membership
object

Membership attributes to update for the user’s relationship with the company. These attributes describe the user’s role or position within the company (e.g., “role”, “department”, “join_date”). They can be used in the Usertour UI just like company attributes.

Returns

A Promise that resolves when the group association is complete.

Example

// Associate user with a company and update attributes
usertour.group('comp_123456', {
  name: 'Acme Corp',
  industry: 'Technology',
  employee_count: 500
}, {
  membership: {
    role: 'admin',
    department: 'engineering',
    join_date: '2023-01-01T00:00:00.000Z'
  }
});

Notes

  • Call this method when a user starts working with a specific company
  • Call again when the user switches to a different company
  • Company attributes are merged with existing values
  • Membership attributes describe the user’s relationship with the company
  • All attributes can be used in flow conditions and content