PostHog Integration
Stream live events into Product Analyst AI via PostHog Webhook Destinations
Overview
PostHog Webhook Destinations forward individual events to an HTTP endpoint as they occur. Product Analyst AI receives each event, normalizes it, and makes it immediately available to the agent and the alert evaluator — no polling, no batch delay.
Setup takes about two minutes. If your product is used by teams or organizations, there's also a B2B section below on linking events to accounts using PostHog group analytics.
Contents
- Setup (4 steps)
- Track companies and accounts (B2B)
- Example payload
- Deduplication
- Historical data
- Other data sources
Setup
1. Find your Company ID
Your Company ID is in Settings → Company. Copy it — you'll paste it into the PostHog webhook URL in the next step.
2. Create a Webhook Destination in PostHog
Open PostHog webhook setup →(EU? Use eu.posthog.com)
Set the URL to:
https://productanalyst.ai/api/integrations/posthog/webhook?company_id=YOUR_COMPANY_IDReplace YOUR_COMPANY_ID with the ID from Step 1. Leave everything else at its default — PostHog's standard JSON body is what we expect.
Keep this URL confidential. The company_id query parameter is the only thing authenticating your webhook — anyone with the URL can send events into your workspace. Treat it like an API key.3. Set an event filter (optional)
To keep ingest volume (and cost) down, add a filter: Event name is one of and list the events you care about (e.g. upgrade_clicked, invite_sent, signed_up). Skip this step to forward every event.
4. Verify events are arriving
Trigger an event in your product, then check the delivery logs in PostHog — you should see a 200 OK response within a few seconds. You can also ask the agent "Show me the last events you received" to confirm the events landed.
Track companies and accounts (B2B)
If your product is used by teams, workspaces, or organizations, link each event to the company it came from. This unlocks account-level questions like "which accounts are churning?" or "show me behavior inside Acme Corp."
There are two ways to do this, depending on how you've set up PostHog:
Option A: PostHog Group Analytics (recommended)
If you use PostHog group analytics, we automatically pick up the account ID from your group key. Nothing extra to configure — just make sure you're calling posthog.group() in your app:
posthog.group('company', 'acme-corp-123')We extract the account ID from the following places, in order:
$group_key— the primary group key$group_0— PostHog's first group slot$groups.company$groups.organization
Option B: Person properties
If you're not using group analytics, you can still attach the company name to each user via posthog.identify(). We read the first non-empty value from company, account, or organization in the user's properties:
posthog.identify('user-42', {
company: 'Acme Inc',
plan: 'pro',
})This populates the company property on every event but won't give you a stable account ID for joins — use Option A if you can.
Consumer app? No companies? Skip this section entirely. Events still flow through end-to-end without any account information, and everything else works as expected.
Example payload
PostHog sends one event per POST. Properties prefixed with $ are PostHog internals ($browser, $current_url, etc.) and are stripped before storage — except for group analytics fields, which we read to extract the account ID.
{
"event": {
"uuid": "01942e1a-...",
"event": "upgrade_clicked",
"distinct_id": "user-42",
"timestamp": "2026-01-15T10:00:00Z",
"properties": {
"plan": "pro",
"$group_0": "acme-corp-123", // read → accountId
"$groups": { "company": "acme-corp-123" },
"$browser": "Chrome", // stripped
"$current_url": "..." // stripped
}
},
"person": {
"id": "...",
"properties": {
"email": "[email protected]",
"company": "Acme Inc" // read → properties.company
}
}
}Deduplication
Each event is deduped on its event.uuid. Duplicate deliveries are silently ignored, so PostHog retries are safe and will never double-count.
Historical data
The webhook only captures events from the moment you connect it — PostHog doesn't replay history into new destinations. To backfill, export events from PostHog as CSV and use the CSV Import in Settings → Integrations.
Other data sources
Not on PostHog? You can capture events directly with the PAI JavaScript SDK — a lightweight autocapture snippet (~1.5KB) that tracks pageviews, clicks, and custom events, with first-class support for B2B accounts via pai.group().