Skip to main content
Salesforce → PostHogIntegration guide

Connecting Salesforce to PostHog

Salesforce holds the opportunity, the amount and the close — the only place the actual revenue outcome is recorded. 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 Salesforce Lead or Opportunity 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

Salesforce deal outcomes as PostHog group properties

Store PostHog's organization or workspace ID on the Salesforce Account, and send deal state as group properties: stage, amount, close date and plan. Send events only for funnel transitions such as deal won, attached to the group. Decide which side is parent when one Account owns several workspaces, and consider importing Salesforce tables into PostHog's warehouse.

PostHog in a B2B SaaS product usually runs group analytics keyed on your organization or workspace ID, which shows product usage per customer account. Salesforce holds the deal for that same account. The join is that org ID stored on the Salesforce Account; without it, Salesforce knows a company name and PostHog knows a workspace, and nothing reliable connects them.

Send deal state as group properties rather than events: stage, amount, close date, plan. A deal belongs to an account, not to whichever user happens to be the main contact, and properties overwrite cleanly when a deal is reopened or a stage changes. Send events only for transitions you want in funnels, such as deal won, attached to the group. Then a funnel from sign-up to activation to deal won can be split by the first-touch source PostHog captured on the users. Check also whether PostHog's data warehouse can import your Salesforce tables; joining in SQL may be simpler than pushing anything.

The usual break is cardinality. One enterprise Account in Salesforce may own several workspaces in the product, and one workspace may have been bought by a subsidiary with its own Account. Decide which side is the parent and write the mapping down before sending properties.

Salesforce → PostHog · what breaks

Why this join usually fails — Salesforce → PostHog

  1. 01

    The distinct_id never reaches Salesforce

    Lead conversion is where identifiers die. A custom field on Lead that has no mapped counterpart on Contact or Opportunity is silently discarded when the Lead converts, and nobody notices until months of data are unattributable.

  2. 02

    The identifier is lost at lead conversion

    This one failure explains most broken Salesforce attribution. The data is captured correctly, then thrown away by a mapping nobody configured.

  3. 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.

  4. 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.

Salesforce → PostHog · the fix

What working looks like — Salesforce → PostHog

  • The distinct_id on every opportunity

  • Conversions arriving in PostHog

    The event lands on the person profile and becomes available in insights, funnels and session replay.

  • Reconciled against the source

Salesforce → PostHog · architecture

How Salesforce and PostHog actually connect

  1. 1

    Salesforce holds the truth

    The opportunity carries the amount, stage and close date. Because Leads convert into Contacts, Accounts and Opportunities, the identifier must be mapped through the conversion or it is dropped exactly at the moment the record becomes valuable.

  2. 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. 3

    The identifier is the bridge

    The distinct_id, captured at the visit and carried into the Salesforce Lead or Opportunity.

  4. 4

    The event source decides reliability

    Fire on the transition into Closed Won, carrying the amount and the identifier. Note that Salesforce's own advertising integrations vary in what they support — build on the record, not on a connector that might change.

  5. 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.

Salesforce → PostHog · normal or broken

Working vs. broken, side by side — Salesforce → PostHog

Normal, not a fault

  • The distinct_id present on the opportunity

  • Sent from a Salesforce flow, Apex trigger or scheduled export on StageName change

  • 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

    Lead conversion is where identifiers die. A custom field on Lead that has no mapped counterpart on Contact or Opportunity is silently discarded when the Lead converts, and nobody notices until months of data are unattributable.

  • Sent from the browser

    This one failure explains most broken Salesforce attribution. The data is captured correctly, then thrown away by a mapping nobody configured.

  • 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

Salesforce → PostHog · diagnose

Diagnostic order — Salesforce → PostHog

  1. 01

    Count opportunitys carrying the distinct_id

  2. 02

    Follow one real conversion end to end

  3. 03

    Convert a test Lead and inspect the resulting Opportunity

    If the identifier is not on the Opportunity, the field mapping is missing. This takes five minutes and rules out the most likely cause outright.

  4. 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.

  5. 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.

Salesforce → PostHog · prove

How it gets proven — Salesforce → PostHog

Source of truth

A Salesforce report of Closed Won opportunities for the same window, by close date.

  • The distinct_id confirmed present on a live opportunity.
  • Purchase events reconciled per transaction against your billing system, with ingestion lag checked over the same window.
  • A test lead converted end to end with the identifier confirmed present on the resulting opportunity.

Salesforce → PostHog · free audit

What we check in the free audit

  • Count opportunitys carrying the distinct_id
  • Follow one real conversion end to end
  • Convert a test Lead and inspect the resulting Opportunity
  • Check ingestion health and disk before debugging any missing event
  • Read the match rate, not the success message

Checked against

A Salesforce report of Closed Won opportunities for the same window, by close date.

Get my free conversion tracking audit

Free30 minutesNo obligation

Salesforce → PostHog · when not to buy

When you don't need this — Salesforce → PostHog

  • Measure identifier coverage yourself first — pull your last hundred opportunitys and count how many carry the distinct_id.
  • If your Salesforce instance is heavily customized and administered by another team, scope their availability before commissioning this — the build is usually blocked on admin access rather than on the tracking work.
  • 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.

Salesforce → PostHog · what we deliver

What gets built — Salesforce → PostHog

  • Identifier capture into Salesforce

    Custom field on Lead, matching custom field on Contact and Opportunity, and the field mapping configured so conversion carries it across. Verify by converting a test lead and reading the resulting opportunity.

  • Event source: a Salesforce flow, Apex trigger or scheduled export on StageName change

    Fire on the transition into Closed Won, carrying the amount and the identifier. Note that Salesforce's own advertising integrations vary in what they support — build on the record, not on a connector that might change.

  • 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

    An opportunity moved back out of Closed Won can be retracted, and enterprise pipelines do this often enough to be worth wiring.

Written guarantee

95%+ tracking accuracy

Measured against A Salesforce report of Closed Won opportunities for the same window, by close date.. Miss it and we keep working at no cost.

Get my free conversion tracking audit

From $400 · See packages

FAQ

Salesforce → PostHog questions, answered

Store your product's organization ID on the Salesforce Account and send deal stage and amount as properties on the matching PostHog group. Account-level data belongs on the group, not on one user.

Free · 30 min

Get Salesforce and PostHog joined properly

Free30 minutesNo obligation