Integrating event tracking lets us know when users complete key activities throughout your application.
This consists of three easy steps:
Make a tracking plan · 1 hour
Identify your users · 5 minutes
Send your first event · 5 minutes
Next steps · 5 minutes
If you haven't installed June's script yet, don't panic! Head over to the Quick Start Guide.
Making a tracking plan
First and foremost, it's important to assess your key performance indicators and figure out what's most important to track. This reduces noise in your reports and focuses your organization on the right metrics.
As a starting point, ask yourself:
What are your key performance indicators (KPIs)?
What essential user actions move these KPIs?
We have many resources available to help you make the right choices.
It's imperative to make sure you identify users once you log in.
This means sending an analytics.identify call once they sign in, and sending analytics.reset once they sign out.
Your call should contain a unique user ID, and optionally any accompanying traits you'd like to track.
1
// Assuming using the inline browser script, we use window.analytics.
2
3
// Send an identify call once the user signs in.
4
asyncfunctionsignIn(username, password){
5
const user =awaitlogin(username, password);
6
// ... user variable contains a JSON object identifying the user:
7
// e.g. {id: 1, first_name: "Enzo", last_name: "Avigo", favorite_color: "blue"}
You can find more information about identifying users on the dedicated Identifying Users guide.
Send your first event
Next up, it's time to send your first event. This could be when a user purchases a product, creates an account, or any other event
affecting key performance indicators.
Your call must include an event name. Optionally, you can pass any other data you'd like
to keep to describe this event.
Finally, it's important to know how to track groups. This is especially imperative for B2B
companies. Using this feature you can gain better insights about how groups of users
behave within your app.
The analytics.group() call associates the current user (recall when we called
analytics.identify()) with a company or organization.
1
// Send an identify and group call once the user signs in.
2
asyncfunctionsignIn(username, password){
3
const user =awaitlogin(username, password);
4
// ... user variable contains a JSON object identifying the user:
5
// e.g. {id: 1, first_name: "Enzo", last_name: "Avigo", favorite_color: "blue"}