Connecting Clerk to PostHog
Clerk handles both authentication and organisation membership, which matters for B2B products where the paying entity is a company and the signing-up entity is a person. PostHog can be self-hosted, which changes the calculus entirely: the data stays on infrastructure you control, and so does the responsibility for everything that goes wrong with it. The join between them succeeds or fails on one thing: whether the distinct_id reaches the Clerk user and organisation before the conversion happens, because PostHog can only match a conversion it can tie back to a click it recognizes.
Free30 minutesNo obligation
Specific to this pair
PostHog groups from Clerk organizations for B2B funnels
Call PostHog identify with the Clerk user ID after sign-in and group with a company group type keyed on the Clerk organization ID, re-calling group when users switch organizations. Send the paid conversion once per organization from billing, naming the organization in groups, with the invoice ID as event UUID.
PostHog and Clerk fit closely. Call identify with the Clerk user ID after sign-in so anonymous pre-sign-up events merge into the user, and call group with a company group type keyed on the Clerk organization ID so every event also lands on the organization. Group analytics, which you should confirm your plan includes, then answers the B2B question directly: how many organizations, not users, reached activation.
Organization switching needs care. A user in two Clerk organizations who switches the active one must trigger a new group call, or their events keep landing on the previous organization; hook it to Clerk's active-organization change in the front end. Server-side events, such as the paid invoice from billing, should name the organization in their groups property explicitly, because the server has no browser state to inherit it from.
Send the paid conversion once per organization from billing, with the invoice ID as the event UUID so a retried webhook does not duplicate it, and copy the creator's first-touch campaign properties onto the organization. That gives a funnel from campaign to paid organization inside PostHog with no third-party pixel involved, which matters when a good share of a developer audience runs ad blockers.
Clerk → PostHog · what breaks
Why this join usually fails — Clerk → PostHog
- 01
The distinct_id never reaches Clerk
Several people from one company sign up separately, each carrying a different acquisition source.
- 02
Counting seats instead of customers
Five colleagues signing up from one company is one paying customer and five conversions if attribution sits on the user. Cost per acquisition then reads as a fifth of reality.
- 03
Self-hosting the analytics and the outage together
The advantage of owning the pipeline is that nothing blocks it. The cost is that when the ingestion instance fills its disk on a Saturday, the events are gone and nobody is paged. Hosted tools fail differently and more visibly.
- 04
Nothing reconciles afterwards
PostHog shows events in the activity view within moments. On a self-hosted instance, check the ingestion lag as well — events that are queued are not events that are lost, and the two need different responses.
Clerk → PostHog · the fix
What working looks like — Clerk → PostHog
The distinct_id on every account
Conversions arriving in PostHog
The event lands on the person profile and becomes available in insights, funnels and session replay.
Reconciled against the source
Clerk → PostHog · architecture
How Clerk and PostHog actually connect
- 1
Clerk holds the truth
In B2B SaaS the subscription belongs to an organisation and several users belong to it. Attributing revenue per user counts one customer several times.
- 2
PostHog needs a click to match
PostHog needs a distinct_id, an event name and its properties. Self-hosted instances additionally need the ingestion endpoint reachable and the project API key correct, which is a class of failure hosted tools do not have.
- 3
The identifier is the bridge
The distinct_id, captured at the visit and carried into the Clerk user and organisation.
- 4
The event source decides reliability
Send paid conversions per organisation, deduplicated across its users.
- 5
Deduplication at the destination
PostHog deduplicates on the event UUID where supplied. Without one, a retried batch duplicates, and on a self-hosted instance there is no vendor support desk to notice it for you.
Clerk → PostHog · normal or broken
Working vs. broken, side by side — Clerk → PostHog
Normal, not a fault
The distinct_id present on the account
Sent from your billing system, keyed on the organisation
Deduplicated correctly
PostHog deduplicates on the event UUID where supplied. Without one, a retried batch duplicates, and on a self-hosted instance there is no vendor support desk to notice it for you.
Reconciles with the source
Actually broken
The distinct_id missing on most records
Several people from one company sign up separately, each carrying a different acquisition source.
Sent from the browser
Five colleagues signing up from one company is one paying customer and five conversions if attribution sits on the user. Cost per acquisition then reads as a fifth of reality.
Counted twice, or not at all
The advantage of owning the pipeline is that nothing blocks it. The cost is that when the ingestion instance fills its disk on a Saturday, the events are gone and nobody is paged. Hosted tools fail differently and more visibly.
Nobody has reconciled it
Clerk → PostHog · diagnose
Diagnostic order — Clerk → PostHog
- 01
Count accounts carrying the distinct_id
- 02
Follow one real conversion end to end
- 03
Compare user signups against paying organisations
The ratio is the size of the overcount, and in B2B products it is rarely close to one.
- 04
Check ingestion health and disk before debugging any missing event
On self-hosted instances the answer is infrastructure far more often than it is instrumentation.
- 05
Read the match rate, not the success message
PostHog shows events in the activity view within moments. On a self-hosted instance, check the ingestion lag as well — events that are queued are not events that are lost, and the two need different responses.
Clerk → PostHog · prove
How it gets proven — Clerk → PostHog
Source of truth
Your billing system, joined to the Clerk organisation rather than the user.
- The distinct_id confirmed present on a live account.
- Purchase events reconciled per transaction against your billing system, with ingestion lag checked over the same window.
- Paid conversions reconciled per organisation against imported conversions, deduplicated across users.
Clerk → PostHog · free audit
What we check in the free audit
- Count accounts carrying the distinct_id
- Follow one real conversion end to end
- Compare user signups against paying organisations
- Check ingestion health and disk before debugging any missing event
- Read the match rate, not the success message
Checked against
Your billing system, joined to the Clerk organisation rather than the user.
Free30 minutesNo obligation
Clerk → PostHog · when not to buy
When you don't need this — Clerk → PostHog
- Measure identifier coverage yourself first — pull your last hundred accounts and count how many carry the distinct_id.
- Consumer products where one user is one customer do not have this distinction.
- If you have no reason to keep the data on your own infrastructure and no team to run it, the hosted product removes the only real downside of this one.
Clerk → PostHog · what we deliver
What gets built — Clerk → PostHog
Identifier capture into Clerk
Store the identifier on the user and attribute at the organisation, using the first user's source with the others recorded as supporting.
Event source: your billing system, keyed on the organisation
Send paid conversions per organisation, deduplicated across its users.
Dispatch to PostHog
The PostHog capture API, posted server-side from your backend to your own instance or to PostHog Cloud.
Reversals where they exist
Cancellations reverse against the organisation.
Written guarantee
95%+ tracking accuracy
Measured against Your billing system, joined to the Clerk organisation rather than the user.. Miss it and we keep working at no cost.
From $400 · See packages
FAQ
Clerk → PostHog questions, answered
Call group with a company group type and the Clerk organization ID after sign-in, and again whenever the user switches organizations.
Yes. Identify with it after sign-in so pre-sign-up anonymous events merge into the same person.
Almost always because the distinct_id never reached the Clerk user and organisation. Several people from one company sign up separately, each carrying a different acquisition source. Measure coverage before debugging the dispatch.
PostHog identifies by distinct_id with an alias call to merge anonymous and identified users. On a self-hosted instance you also control the ingestion endpoint, which means the identifier survives ad blockers that would kill a third-party pixel — one of the few genuine technical advantages available to a first-party setup.
Your billing system, keyed on the organisation. Send paid conversions per organisation, deduplicated across its users.
PostHog shows events in the activity view within moments. On a self-hosted instance, check the ingestion lag as well — events that are queued are not events that are lost, and the two need different responses.
More on Clerk → PostHog
- Stripe → PostHogConnecting Stripe to PostHog
- PayPal → PostHogConnecting PayPal to PostHog
- Shopify → PostHogConnecting Shopify to PostHog
RELATED GUIDES
Where Clerk → PostHog fits in the rest of your tracking
- Okta → PostHogConnecting Okta to PostHog
- Firebase Auth → PostHogConnecting Firebase Authentication to PostHog
- Auth0 → PostHogConnecting Auth0 to PostHog
- Clerk → MatomoConnecting Clerk to Matomo
- Clerk → MixpanelConnecting Clerk to Mixpanel
- B2BConversion tracking for B2B, from first touch to closed-won
- Supabase Auth → PostHogConnecting Supabase Auth to PostHog
Free · 30 min
Get Clerk and PostHog joined properly
Free30 minutesNo obligation
