> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/mixpanel/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Company Analytics

> Track company-level data and B2B metrics

## Overview

If you're building a B2B product, you'll want to track data at both the user level and the company level. Mixpanel's Group Analytics allows you to analyze behavior by company, team, workspace, or any other group entity.

<Note>
  Company Analytics requires Group Analytics, which is available on Growth and Enterprise plans. [Learn more about pricing](https://mixpanel.com/pricing).
</Note>

## Why Track Company Data?

Tracking at the company level allows you to:

* Understand which companies are most engaged
* Track account-level metrics like total users, activity, and health scores
* Build reports showing company-level adoption and usage
* Identify expansion opportunities
* Monitor churn risk at the account level

## Setting Up Company Analytics

### Step 1: Define Your Group Key

First, decide what identifier you'll use for companies. Common choices:

* `company_id` - Your internal company identifier
* `account_id` - Account ID from your database
* `organization_id` - Organization identifier

### Step 2: Send Group Data with Events

When tracking events, include the group identifier:

<Tabs>
  <Tab title="JavaScript">
    ```javascript theme={null}
    // First, add the user to a group
    mixpanel.set_group('company_id', 'acme_corp');

    // Then track events as normal
    mixpanel.track('Feature Used', {
      'Feature Name': 'Dashboard'
    });

    // The company_id will automatically be included
    ```
  </Tab>

  <Tab title="Python">
    ```python theme={null}
    # Track an event with group data
    mp.track('user_123', 'Feature Used', {
        'Feature Name': 'Dashboard',
        '$groups': {
            'company_id': 'acme_corp'
        }
    })
    ```
  </Tab>

  <Tab title="Node.js">
    ```javascript theme={null}
    // Track an event with group data
    mixpanel.track('Feature Used', {
        distinct_id: 'user_123',
        'Feature Name': 'Dashboard',
        '$groups': {
            'company_id': 'acme_corp'
        }
    });
    ```
  </Tab>
</Tabs>

### Step 3: Set Group Properties

Just like user profiles, you can set properties on groups:

<Tabs>
  <Tab title="JavaScript">
    ```javascript theme={null}
    mixpanel.get_group('company_id', 'acme_corp').set({
      'Company Name': 'Acme Corporation',
      'Industry': 'Technology',
      'Plan': 'Enterprise',
      'Employee Count': 500,
      'MRR': 50000
    });
    ```
  </Tab>

  <Tab title="Python">
    ```python theme={null}
    # Set group properties
    mp.group_set('company_id', 'acme_corp', {
        'Company Name': 'Acme Corporation',
        'Industry': 'Technology',
        'Plan': 'Enterprise',
        'Employee Count': 500,
        'MRR': 50000
    })
    ```
  </Tab>

  <Tab title="Node.js">
    ```javascript theme={null}
    // Set group properties
    mixpanel.groups.set('company_id', 'acme_corp', {
        'Company Name': 'Acme Corporation',
        'Industry': 'Technology',
        'Plan': 'Enterprise',
        'Employee Count': 500,
        'MRR': 50000
    });
    ```
  </Tab>
</Tabs>

## Common Company Properties to Track

<CardGroup cols={2}>
  <Card title="Company Info" icon="building">
    * Company Name
    * Industry
    * Company Size
    * Location/Country
    * Website
  </Card>

  <Card title="Account Details" icon="file-contract">
    * Plan Type
    * MRR/ARR
    * Contract Start Date
    * Renewal Date
    * Number of Seats
  </Card>

  <Card title="Engagement Metrics" icon="chart-line">
    * Active Users Count
    * Last Activity Date
    * Feature Adoption Score
    * Health Score
  </Card>

  <Card title="Success Metrics" icon="trophy">
    * Account Manager
    * CSM Assigned
    * NPS Score
    * Support Tickets
  </Card>
</CardGroup>

## Example: Complete Company Setup

Here's a complete example of setting up company analytics:

```javascript theme={null}
// 1. When user signs in, associate them with their company
mixpanel.identify('user_123');
mixpanel.set_group('company_id', 'acme_corp');

// 2. Set user properties
mixpanel.people.set({
  '$name': 'Jane Doe',
  '$email': 'jane@acme.com',
  'Role': 'Admin'
});

// 3. Set company properties
mixpanel.get_group('company_id', 'acme_corp').set({
  'Company Name': 'Acme Corporation',
  'Plan': 'Enterprise',
  'Employee Count': 500,
  'Industry': 'Technology'
});

// 4. Track events (company_id is automatically included)
mixpanel.track('Report Created', {
  'Report Type': 'Sales Dashboard'
});
```

## Analyzing Company Data

Once you're sending company data, you can:

### 1. View Company Profiles

Navigate to Users > Groups in Mixpanel to see all companies and their properties.

### 2. Build Company-Level Reports

In any Mixpanel report, you can:

* Group by company properties (e.g., Plan Type, Industry)
* Filter by company attributes
* View metrics aggregated at the company level

### 3. Create Company Cohorts

Build cohorts of companies based on:

* Activity levels
* Feature usage
* Plan type
* Health scores

## Best Practices

<Tip>
  **Set the group early**: Call `set_group()` as soon as a user logs in to ensure all subsequent events are associated with the company.
</Tip>

<Tip>
  **Keep properties updated**: Update company properties when important changes occur (plan upgrades, seat changes, etc.).
</Tip>

<Tip>
  **Use consistent IDs**: Use the same company identifier across all your systems for easy data integration.
</Tip>

<Warning>
  **Group Analytics limits**: Each project can have up to 3 group keys. Plan accordingly based on your analysis needs.
</Warning>

## Use Cases

### Track Account Health

```javascript theme={null}
// Update company health score based on activity
function updateCompanyHealth(companyId, activityScore) {
  mixpanel.get_group('company_id', companyId).set({
    'Health Score': activityScore,
    'Last Updated': new Date().toISOString()
  });
}
```

### Monitor Feature Adoption by Company

```javascript theme={null}
// Track when companies adopt new features
mixpanel.track('Feature Enabled', {
  'Feature Name': 'Advanced Reporting'
});

// Update company profile
mixpanel.get_group('company_id', 'acme_corp').set({
  'Advanced Reporting Enabled': true,
  'Features Enabled Count': 12
});
```

### Track Expansion Revenue

```javascript theme={null}
// When a company upgrades
mixpanel.get_group('company_id', 'acme_corp').set({
  'Plan': 'Enterprise',
  'MRR': 50000,
  'Upgrade Date': new Date().toISOString()
});

mixpanel.track('Plan Upgraded', {
  'Previous Plan': 'Professional',
  'New Plan': 'Enterprise',
  'MRR Change': 30000
});
```

## Next Steps

<Card title="Learn More About Group Analytics" icon="book" href="/docs/data-structure/advanced/group-analytics">
  Dive deeper into Group Analytics features and capabilities
</Card>

## FAQ

<AccordionGroup>
  <Accordion title="How many group keys can I have?">
    Each Mixpanel project supports up to 3 group keys. Common setups include:

    * `company_id` for B2B companies
    * `workspace_id` for workspace-based products
    * `team_id` for team-based features
  </Accordion>

  <Accordion title="Can I change group keys later?">
    While technically possible, changing group keys requires re-sending historical data. It's best to plan your group structure carefully from the start.
  </Accordion>

  <Accordion title="How do I handle users in multiple companies?">
    Users can belong to multiple groups. You can update the active group with `set_group()` based on which company context they're currently working in.
  </Accordion>

  <Accordion title="What's the difference between group properties and event properties?">
    * **Group properties**: Attributes of the company itself (name, plan, size) that persist over time
    * **Event properties**: Context about a specific event occurrence (which feature, what value, etc.)

    Both are useful for analysis but serve different purposes.
  </Accordion>
</AccordionGroup>
