Javascript SDK
Track events that happen on your app's frontend or on your site using the Kompassify Javascript tracking code.
Install the SDK
Make sure to have installed the following Kompassify JS snippet on your website before using the methods below.
<script
id='kompassious'
src='https://player.kompassify.com/kompassifyPlayer.js?uuid=YOUR_ACCOUNT_ID'
type='text/javascript'
async
></script>
Identify User
The identify method can be used to:
- Uniquely identify the current user.
- Enrich his or her profile with additional traits
We recommend calling identify on the following events:
- After a user registers
- After a user logs in
- When a user updates their info (for example changes his plan or updates his address)
window.KompassifyJS?.identifyUser({
userId: 'user_id', // (required), A unique user identifier
});
Identify company
When multiple users belong to the same company you can link the user to the company by specifying the attribute companyId when calling window.KompassifyJS?.identifyUser
window.KompassifyJS?.identifyUser({
userId: 'user_id', // (required), A unique user identifier
companyId: 'company_id', // (optional) if the user or multiple users belong to the same company
});
Enrich or Update User profile
You can use the identifyUser method to enrich or update your user's profile
window.KompassifyJS?.identifyUser({
userId: 'unique_user_id', // (required)
firstName: 'first_name',
lastName: 'last_name',
companyId: 'unique_company_id',
companyName: 'company_name',
email: 'user_email',
plan: 'pricing_plan',
segments: ['NEW_USER', 'TRIAL', 'CHOOSE_A_SEGMENT'],
registrationDate: new Date(),
extraAttributes: {
// add your custom attributes here
myCustomAttribute: 'you_can_add_custom_attributes_here',
anotherAttribute: 'you_can_add_custom_attributes_here',
},
});
Track User
To track the user's activity within your app use the track method, Passing additional information is possible using the properties object.
window.KompassifyJS?.trackUser({
event: 'Example event', // (required)
properties: {
exampleProp1: 'EXAMPLE_VALUE1', // (optional)
exampleProp2: 'EXAMPLE_VALUE1', // (optional)
},
});
Check the events page
🎉 Congratulations, you've tracked your first event! You can see it in Kompassify via the Events page.