Skip to main content
Swell → PostHogIntegration guide

Connecting Swell to PostHog

Swell is headless commerce with subscriptions built in, which puts two conversion types in one system: a one-off order and a recurring plan that will bill again next month. 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 Swell order 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

Swell orders in PostHog on the same distinct_id

Call identify with the Swell account ID at login or checkout and send webhook events with the same ID. For guests, pass PostHog's anonymous ID into cart metadata and alias it to the account ID when the order is paid. Send renewal paid, payment failed, paused and canceled events with UUIDs derived from Swell order or invoice IDs.

PostHog is where a headless Swell storefront can see its own funnel: product view, cart, checkout, paid order, then renewals and cancellations, all on one person. That only works if the distinct_id is the same in the browser and in the server events. Call identify with the Swell account ID when the shopper logs in or checks out, and send server events from Swell webhooks with that same ID.

Guest checkout is the gap. A shopper who never logs in stays on an anonymous ID in the browser, and if the webhook sends the order under the Swell account ID that Swell created for the guest, PostHog sees two people. Pass the anonymous ID into the Swell cart's metadata and alias it to the account ID when the order is paid, so the pre-purchase session and the order land on one person.

Unlike ad platforms, PostHog is a good home for renewals. Send renewal paid, payment failed, paused and canceled as separate events, and retention charts show which acquisition sources produce subscribers who stay. Set a UUID on each server event derived from the Swell order or invoice ID, so a webhook retry does not duplicate it; on a self-hosted instance nobody else will catch that.

Swell → PostHog · what breaks

Why this join usually fails — Swell → PostHog

  1. 01

    The distinct_id never reaches Swell

    Headless storefront plus recurring billing means the renewal happens months later with no session and no storefront involved.

  2. 02

    Renewals indistinguishable from new orders

    In a combined store the export gives you a list of payments. Without a first-versus-renewal flag, a customer on a monthly plan generates a conversion every month against the click that acquired them once.

  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.

Swell → PostHog · the fix

What working looks like — Swell → PostHog

  • The distinct_id on every order

  • Conversions arriving in PostHog

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

  • Reconciled against the source

Swell → PostHog · architecture

How Swell and PostHog actually connect

  1. 1

    Swell holds the truth

    A subscription's first payment and its renewals are the same object type in most exports. Sending both means one acquisition produces a conversion every billing cycle.

  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 Swell order.

  4. 4

    The event source decides reliability

    Send one-off orders and first subscription payments. Renewals belong in a retention figure.

  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.

Swell → PostHog · normal or broken

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

Normal, not a fault

  • The distinct_id present on the order

  • Sent from the Swell order and subscription webhooks

  • 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

    Headless storefront plus recurring billing means the renewal happens months later with no session and no storefront involved.

  • Sent from the browser

    In a combined store the export gives you a list of payments. Without a first-versus-renewal flag, a customer on a monthly plan generates a conversion every month against the click that acquired them once.

  • 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

Swell → PostHog · diagnose

Diagnostic order — Swell → PostHog

  1. 01

    Count orders carrying the distinct_id

  2. 02

    Follow one real conversion end to end

  3. 03

    Compare monthly conversion count against new customer count

    If conversions exceed new customers, renewals are being counted as acquisition.

  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.

Swell → PostHog · prove

How it gets proven — Swell → PostHog

Source of truth

Swell orders and subscriptions by date, held apart from each other.

  • The distinct_id confirmed present on a live order.
  • Purchase events reconciled per transaction against your billing system, with ingestion lag checked over the same window.
  • First payments reconciled against imported conversions, with renewals reported separately.

Swell → PostHog · free audit

What we check in the free audit

  • Count orders carrying the distinct_id
  • Follow one real conversion end to end
  • Compare monthly conversion count against new customer count
  • Check ingestion health and disk before debugging any missing event
  • Read the match rate, not the success message

Checked against

Swell orders and subscriptions by date, held apart from each other.

Get my free conversion tracking audit

Free30 minutesNo obligation

Swell → PostHog · when not to buy

When you don't need this — Swell → PostHog

  • Measure identifier coverage yourself first — pull your last hundred orders and count how many carry the distinct_id.
  • A store selling only one-off products does not have the renewal problem.
  • 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.

Swell → PostHog · what we deliver

What gets built — Swell → PostHog

  • Identifier capture into Swell

    Write the identifier into customer metadata so the first payment can be attributed and renewals can be recognised as renewals.

  • Event source: the Swell order and subscription webhooks

    Send one-off orders and first subscription payments. Renewals belong in a retention figure.

  • 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

    Refunds and cancellations inside the first period reverse.

Written guarantee

95%+ tracking accuracy

Measured against Swell orders and subscriptions by date, held apart from each other.. Miss it and we keep working at no cost.

Get my free conversion tracking audit

From $400 · See packages

FAQ

Swell → PostHog questions, answered

Identify users with the Swell account ID in the browser, and send server events from Swell webhooks with the same distinct_id.

Free · 30 min

Get Swell and PostHog joined properly

Free30 minutesNo obligation