Home
Quick start
Identifying users
Tracking events
Tracking groups

Technical Guides

Browser
Node.js
License
Sign in

Tracking Groups

Learn how to group users

What we'll cover

Tracking groups is essential when working with companies and segmenting your user base.

This consists of two steps, taking no more than 15 minutes.

  • Identifying users · 10 minutes
  • Tracking groups · 5 minutes

Identifying users

It's imperative to set up your user identification calls before tracking groups. Otherwise, it won't work.

1
// Send an identify call once the user signs up.
2
async function signUp(username, password) {
3
const user = await register(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"}
6
window.analytics.identify(user.id, { favorite_color: user.favorite_color });
7
}

Check the dedicated Identifying Users guide for more information.

Tracking Groups

Let's track your first group! Using this feature you can gain better insights about how groups of users behave within your app.

This feature piggybacks on the analytics.identify call we set up on the previous step.

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
async function signIn(username, password) {
3
const user = await login(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"}
6
window.analytics.identify(user.id, { favorite_color: user.favorite_color });
7
// We group the user. <---
8
window.analytics.group('June HQ', { industry: 'Technology' });
9
}

Next steps

Congrats, you're done! Here's other guides to check out: