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

# B2B and Account Analytics

> Measure companies, workspaces, or teams as accounts, with account-level funnels, retention, active counts, filters, and feature flags.

Group analytics answers a B2B question that per-person metrics can't: **how many accounts**, not just how many people. You tag events with the account they belong to — a company, workspace, or team — and then funnels, retention, active counts, and filters can all roll up to account grain, where every seat in one company counts as one account.

## How do I tag events with an account?

Associate the current visitor with an account by calling `window.tinyanalytics.group()`. From then on, every event that visitor sends is tagged with that account:

```js theme={null}
// type, account key, optional traits
window.tinyanalytics.group('company', 'acme-inc', {
  name: 'Acme Inc',
  plan: 'enterprise'
})
```

* A site can register up to **5 group types** (for example `company`, `workspace`). The first types you send claim the slots.
* Pass **traits** to describe the account — its name, plan, or size — the same way [user traits](/docs/user-identification-analytics) describe a person. Update them later with `setGroupTraits(type, traits)`.
* Call `resetGroups()` to forget the associations, for example when a user logs out.

<Note>
  `group()` persists the associations you provide in browser storage so later events keep their account context. Call `resetGroups()` at logout, and review [Privacy & GDPR](/docs/resources/privacy-friendly-analytics-gdpr) when assessing consent requirements.
</Note>

## How do I switch reports to account grain?

Use the **grain toggle** on the dashboard. Once events are tagged, it swaps person-level metrics for account-level ones. The Users card becomes **active accounts** — the number of distinct accounts active in the period — and you can:

* **Filter** to one account's activity, keeping every event in that account's sessions.
* **Break down** any report by account to see your top companies.

## How do account-grain funnels and retention work?

[Funnels](/docs/funnel-analytics) and [retention](/docs/user-retention-analytics) can measure the **account** instead of the session or person. This changes what "completed" and "returned" mean:

* A funnel step counts for an account when **any member, in any session** reaches it — so a company converts even if one person started the trial and a colleague finished it.
* An account is retained when **any seat returns** in a later period, so a returning team reads as one retained account rather than several individual visitors.

## What else does account grain unlock?

Two more things:

* **Inactivity alerts** — get notified when an account that used to be active goes quiet, so you can reach out before it churns. See [alerts](/docs/analytics-alerts).
* **Flag targeting by account** — evaluate a [feature flag](/docs/feature-flag-analytics) per account so every seat in one company shares the same rollout, and rollout percentages count accounts rather than people.

## Frequently asked questions

<AccordionGroup>
  <Accordion title="How many group types can one site have?">
    Up to **5**. A tinyanalytics site can register five group types — for example `company` and `workspace` — and the first types you send claim the slots.
  </Accordion>

  <Accordion title="When does a funnel step count for a whole account?">
    When **any member, in any session** reaches it. An account-grain funnel in tinyanalytics credits the account even if one person started the trial and a colleague finished it. Retention works the same way: an account is retained when any seat returns in a later period.
  </Accordion>

  <Accordion title="How do I clear a visitor's account association when they log out?">
    Call `resetGroups()`. It forgets the associations set by `window.tinyanalytics.group()`, so events the visitor sends afterward aren't tagged with the previous account.
  </Accordion>
</AccordionGroup>

## Related

<Columns cols={2}>
  <Card title="Identify users" icon="user" href="/docs/user-identification-analytics">
    Tag the individual people inside each account.
  </Card>

  <Card title="Alerts" icon="bell" href="/docs/analytics-alerts">
    Get notified when an account goes quiet.
  </Card>

  <Card title="Feature flags" icon="toggle-on" href="/docs/feature-flag-analytics">
    Roll a feature out by account.
  </Card>

  <Card title="Retention" icon="repeat" href="/docs/user-retention-analytics">
    Measure whether accounts come back.
  </Card>
</Columns>


## Related topics

- [Feature Flag Analytics](/docs/feature-flag-analytics.md)
- [Analytics Alerts](/docs/analytics-alerts.md)
- [Identify Users API](/docs/api-reference/identify-users-api.md)
