1window.analytics.identify('USER_ID', { 2email: 'test@example.com', 3// Optional 4name: 'Joe Bloggs', 5avatar: 'https://avatar.com/asd809sdhoif9as10nc29.png' 6// Add anything else about the user here 7});
If you haven't installed one of the June SDKs, please do that first before implementing the .identify
method.
This section provides guidance on using the identify
method to successfully identify your product's users. This will show you which users are triggering events in June. It is recommended to include this code snippet in the section of your code where user sign-ups, logins, or account details updates are handled.
Replace USER_ID
with a unique identifier, preferably the user ID from your database. Including the user's email is also suggested, along with any additional "traits" like avatar, name, role, etc. This information will appear on the user's profile and can be used to filter users in reports.
1window.analytics.identify('USER_ID', { 2email: 'test@example.com', 3// Optional 4name: 'Joe Bloggs', 5avatar: 'https://avatar.com/asd809sdhoif9as10nc29.png' 6// Add anything else about the user here 7});
1analytics.identify('USER_ID',{ 2email: 'test@example.com', 3// Optional 4name: 'Joe Bloggs', 5avatar: 'https://avatar.com/asd809sdhoif9as10nc29.png' 6// Add anything else about the user here 7});
1analytics.identify({ 2userId: 'USER_ID', 3traits: { 4email: 'test@example.com', 5// Optional 6name: 'Joe Bloggs', 7avatar: 'https://avatar.com/asd809sdhoif9as10nc29.png' 8// Add anything else about the user here 9} 10});
1analytics.identify( 2user_id="USER_ID", 3traits={ 4"email": "test@example.com", 5# Optional 6"name": "Joe Bloggs", 7"avatar": "https://avatar.com/0sd9fsd8y97a0sf99asd.png", 8# Add anything else about the user here 9}, 10)
1Analytics.identify( 2user_id: 'USER_ID', 3traits: { 4email: "test@example.com" 5# Optional 6name: "Joe Bloggs", 7avatar: "https://avatar.com/d78979as8hlsa9088f.png" 8# Add anything else about the user here 9} 10)
1curl https://api.june.so/sdk/identify 2-H "Content-Type: application/json" 3-H "Authorization: Basic YOUR_WRITE_KEY" 4-X POST 5 6{ 7"userId": "USER_ID", 8"traits": { 9"email": "test@example.com", 10# Optional 11"name": "Joe Bloggs", 12"avatar": "https://avatar.com/0sd9fsd8y97a0sf99asd.png", 13# Add anything else about the user here 14}, 15"timestamp": "2012-12-02T00:31:38.208Z" 16}
If you're a B2B product, you most likely have actual businesses, known as "companies", using your product. Luckily, June creates them automatically for you by simply implementing an .identify
call with an "email" trait from the previous step.
We use the user's email
trait and automatically create companies based on the domain of the email, e.g. "jeff@amazon.com" would create a company called "amazon.com". This allows you to view your analytics
at the company level. However, if you wish to add additional traits to these companies, you must send a .group
call. Below is how you can achieve that.
In order to send traits to one of the automatically generated companies in June, you need to send a .group
call with an id
as the domain of the company you wish to enrich and a group_type: "company"
as a trait, along
with any additional traits. Here's an example:
1window.analytics.group('amazon.com', { 2group_type: 'company', 3// Add anything else about the company here 4... 5});
1analytics.group('amazon.com', 2{ 3group_type: 'company', 4// Add anything else about the company here 5... 6});
1analytics.group({ 2groupId: 'amazon.com', 3traits: { 4group_type: 'company', 5// Add anything else about the company here 6... 7}, 8});
1analytics.group( 2group_id="amazon.com", 3traits={ 4"group_type": "company", 5# Add anything else about the company here 6... 7}, 8)
1Analytics.group( 2group_id: 'amazon.com', 3traits: { 4group_type: "company", 5# Add anything else about the company here 6... 7} 8)
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"groupId": "amazon.com", 8"traits": { 9"group_type": "company" 10}, 11"timestamp": "2012-12-02T00:31:38.208Z" 12}
If you're a B2B product, you most likely have groups of users using your product, e.g. "workspaces", "organisations" etc. This section provides guidance on using the group
method to successfully identify workspaces, organisations or any other type of user grouping which you may want to capture.
This will allow you to track usage at the "workspace" level in June, as well as viewing individual "workspace" profiles and the users that belong to each workspace. 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, 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: '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: '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: '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": "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: "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 identify
method in your codebase, it's time to track what your users & companies are doing in your product.