1window.analytics.track('Signed In', { 2browser: 'chrome' 3}, { 4// Add the GROUP_ID here to track this event on behalf of a company 5{ context: { groupId: 'GROUP_ID' } } 6});
If you haven't implemented the .group
call, please do that first before implementing the .track
method for companies.
This guide will teach you how to successfully track how your companies are using your product. It's almost identical to tracking user behaviour with the exception of one change.
When triggering track events for a company, you should pass the unique ID (GROUP_ID
) for the company in the context
object of the .track
method. See the code example below.
Note: If you have already implemented the .track
call for users, you can just add the
context
object with the GROUP_ID
. There is no need to add additional .track
calls for companies.
Replace USER_ID
& GROUP_ID
with your own unique identified, ideally the user and workspace ID from your database.
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.track('Signed In', { 2browser: 'chrome' 3}, { 4// Add the GROUP_ID here to track this event on behalf of a company 5{ context: { groupId: 'GROUP_ID' } } 6});
1analytics.track({ 2userId: 'USER_ID', 3event: 'Signed In', 4properties: { 5browser: 'chrome' 6}, 7// Add the GROUP_ID here to track this event on behalf of the company 8context: { 9groupId: 'GROUP_ID' 10} 11});
1analytics.track({ 2userId: 'USER_ID', 3event: 'Signed In', 4properties: { 5browser: 'chrome' 6}, 7// Add the GROUP_ID here to track this event on behalf of the company 8context: { 9groupId: 'GROUP_ID' 10} 11});
1analytics.track( 2user_id="USER_ID", 3event="Signed In", 4properties={"browser": "chrome"}, 5# Add the GROUP_ID here to track this event on behalf of the company 6context={"groupId": "GROUP_ID"}, 7)
1Analytics.track( 2user_id: 'USER_ID', 3event: 'Signed In', 4properties: { 5browser: 'chrome' 6}, 7# Add the GROUP_ID here to track this event on behalf of the company 8context: { 9group_id: 'GROUP_ID' 10} 11)
1curl https://api.june.so/sdk/track 2-H "Content-Type: application/json" 3-H "Authorization: Basic YOUR_WRITE_KEY" 4-X POST 5 6{ 7"userId": "USER_ID", 8"event": "Signed in", 9"properties": { 10"browser": "chrome", 11}, 12"context": { 13"groupId": "GROUP_ID", 14}, 15"timestamp": "2012-12-02T00:31:38.208Z" 16}
Once you've implemented the .identify
, .group
and .track
method and are sending track events, you're ready to jump into June.