Group analytics - Docs - PostHog

Group analytics

Overview

Group analytics aggregates events by entities like organizations or companies instead of individual users. This is useful when you need to track behavior at the company, team, or project level.

With groups, you can:

Key concepts

Group types are categories you define - like "company" or "project". You can create up to 5 group types per project.

Groups are the individual entities within each type. For example, if your group type is "company," each group would be a specific company like "Acme Corp" or "Tech Solutions Inc." You can have unlimited groups within each group type.

How it works

  1. Define group types - like "company" or "channel"
  2. Assign group keys (unique identifiers) to each group
  3. Link events to groups in your code
  4. Analyze data by group instead of by user

Billing

Group analytics is a paid add-on. Here's how billing works:

All identified events count toward billing

Once you subscribe to group analytics, billing applies to all identified events in your project, not just events with group properties attached. This is because group analytics enables infrastructure that processes all identified events to support group-level analysis.

You can see how enabling group analytics affects your pricing on the pricing calculator.

Use cases

B2B product activation

Create a "company" group type to track how companies progress through your B2B product's onboarding with funnels:

Channel retention

Create a "channel" group type for Slack-like apps to measure retention of features by channel:

Project-level feature flags

Create a "project" group type for collaborative apps like Jira, Notion, or Figma:

Cross-product analysis

Group analytics works across PostHog's entire platform. Here's how you can use group types with different products:

Product Functionality Example
Product analytics Aggregate trends, funnels, retention, and stickiness by group Track how many companies completed onboarding
Feature flags Configure release conditions based on groups Ensure all users of a company see the same feature flag variant
Experiments Evaluate experiment results based on group aggregations Run an A/B test to improve activation rate for new companies
Data warehouse Join tables or enrich queries with groups data Write SQL queries that calculate usage across different company sizes

Groups vs cohorts

Groups and cohorts serve different purposes:

Use cohorts if you only need to analyze a list of users. They're simpler and faster to implement.

Set up group analytics

Create group types

Create group types before you associate events with them. Call the group identify method to create a group type and set properties.

In this example, we create a "company" group type. For each individual group (company), we set the group key like an ID or domain:

// Call posthog.group() to create a group before capturing events.
// It sends a `$groupidentify` event to create or update the group.
// It will also create the group type if it doesn't exist. In the
// web SDK, it also associates all subsequent events in the session
// with the group.
posthog.group('company', 'company_id_in_your_db');
// This event will be associated with the company above.
posthog.capture('user_signed_up');

// If the group type is already created, you can also manually add
// the `$groups` property to any event you want to associate with
// the group.
posthog.capture('user_signed_up', {
    '$groups': {
        'company': 'company_id_in_your_db'
    }
});
# Call posthog.group_identify() to create a group before capturing events.
# It sends a `$groupidentify` event to create or update the group.
# It will also create the group type if it doesn't exist.
posthog.group_identify('company', 'company_id_in_your_db')

# Once the group is created, you can associate events with it by
# passing the `group` argument. The `group` argument is required
# for every event that should be associated with the group.
posthog.capture(
    'user_signed_up',
    groups={'company': 'company_id_in_your_db'}
)
// Call posthog.GroupIdentify{} to create a group before capturing events.
// It sends a `$groupidentify` event to create or update the group.
// It will also create the group type if it doesn't exist.
client.Enqueue(posthog.GroupIdentify{
    Type: "company",
    Key:  "company_id_in_your_db",
})

// Once the group is created, you can associate events with it by
// passing the `$groups` property. The `$groups` property is required
// for every event that should be associated with the group.
client.Enqueue(posthog.Capture{
    DistinctId: "user_distinct_id",
    Event: "user_signed_up",
    Groups: posthog.NewGroups().
        Set("company", "company_id_in_your_db"),
})

Using groups in PostHog

View individual groups

To view individual groups and their properties, go to the people tab in the PostHog app and select the group type you want to view. Group types are listed under the Groups section.

Analyze insights by group type

Use insights to view trends aggregated by group type.

Use group types with funnels

Track how individual groups organizations move through conversion steps by setting Aggregating by to your group type.

Use group types with feature flags

Create a feature flag and use the Target by selector on a condition set to choose your group type.