1window.analytics.group('GROUP_ID', { 2name: 'Acme Inc', 3// Optional 4avatar_url: 'https://avatar.com/asd809sdhoif9as10nc29.png 5// Add anything else about the company here 6});
If you haven't implemented the .identify
call, please do that first before implementing the .group
method.
If you're a B2B product, you most likely have multiple users using your product in a "workspace". This document provides guidance on using the group
method to successfully identify companies using your product.
This will allow you to track usage at the company level in June, as well as viewing individual company profiles and the users that belong to each company. It is recommended to include this code snippet in the section of your code next to your identify
call, i.e. where users sign up or login.
Replace USER_ID
and GROUP_ID
with a unique identifier, preferably the user ID and workspace ID from your database. Including the company's name is also suggested, along with any additional "traits" like avatar_url, company_size etc. This information will appear on the companies profile and can be used to filter companies in reports.
In the following example, it's important to call the .identify call before the .group call, because the .group call will attach the current identified user.
1window.analytics.group('GROUP_ID', { 2name: 'Acme Inc', 3// Optional 4avatar_url: 'https://avatar.com/asd809sdhoif9as10nc29.png 5// Add anything else about the company here 6});
In the following example, it's important to call the .identify call before the .group call, because the .group call will attach the current identified user.
1analytics.group('GROUP_ID', 2{ 3name: 'Acme Inc', 4// Optional 5avatar_url: 'https://avatar.com/asd809sdhoif9as10nc29.png' 6// Add anything else about the company here 7});
1analytics.group({ 2userId: 'USER_ID', 3groupId: 'GROUP_ID', 4traits: { 5name: 'Acme Inc', 6// Optional 7avatar_url: 'https://avatar.com/asd809sdhoif9as10nc29.png' 8// Add anything else about the company here 9}, 10});
1analytics.group( 2user_id="USER_ID", 3group_id="GROUP_ID", 4traits={ 5"name": "Acme Inc", 6# Optional 7"avatar_url": "https://avatar.com/0sd9fsd8y97a0sf99asd.png", 8# Add anything else about the company here 9}, 10)
1Analytics.group( 2user_id: 'USER_ID', 3group_id: 'GROUP_ID', 4traits: { 5name: "Acme Inc", 6# Optional 7avatar_url: "https://avatar.com/d78979as8hlsa9088f.png" 8# Add anything else about the company here 9} 10)
1curl https://api.june.so/sdk/group 2-H "Content-Type: application/json" 3-H "Authorization: Basic YOUR_WRITE_KEY" 4-X POST 5 6{ 7"userId": "USER_ID", 8"groupId": "GROUP_ID", 9"traits": { 10"name": "Acme Inc" 11}, 12"timestamp": "2012-12-02T00:31:38.208Z" 13}
Once you've implemented the group
method in your codebase, it's time to track what your companies are doing in your product.