Skip to main content
Sanity → BranchIntegration guide

Connecting Sanity to Branch

Sanity is a headless content platform, which means like every headless CMS it holds no commercial record and the tracking question lives elsewhere. Branch's real job is the web-to-app seam — a person clicks a link in a browser, installs the app, and something has to carry the context across an install that destroys every cookie involved. The join between them succeeds or fails on one thing: whether the Branch link click identifier and the deferred deep link payload reaches the front-end conversion, not a Sanity record before the conversion happens, because Branch can only match a conversion it can tie back to a click it recognizes.

Free30 minutesNo obligation

Specific to this pair

Branch links for Sanity content: identify content by document ID

Put the Sanity document _id, not the slug-based path, in Branch link data so the app opens the same content after a fresh install. If a publish webhook calls Branch's link API and writes the URL back, filter the webhook to ignore that field or it loops. In-app revenue goes server-to-server from your backend; Sanity reports nothing.

Branch fits when the same Sanity content renders on both the website and the app: articles, recipes, guides, product stories. A Branch link should carry the identity of the content so the app opens the same piece after a fresh install. Use the Sanity document _id as the canonical content identifier in the link data rather than the URL path, because paths are built from slugs editors can change, and a deferred deep link that resolves to a missing path drops the new user on a generic screen.

Links are often generated at publish time: a Sanity webhook fires on publish, a small function calls Branch's link API, and the resulting URL is written back into the document. That write-back is itself an update, which fires the webhook again. Filter the webhook so changes to the link field alone do not trigger it, or you create a loop of new links and spend your API limits on one article.

Revenue in the app goes to Branch server-to-server from your backend with the event identifier your SDK also uses. Sanity has nothing to report. Test the whole path on a real iOS device with the app deleted: tap a link on an article, install, open, and confirm the app queries Sanity by the ID it received.

Sanity → Branch · what breaks

Why this join usually fails — Sanity → Branch

  1. 01

    The Branch link click identifier and the deferred deep link payload never reaches Sanity

    The front-end application does the routing, the caching and the identifier capture. Single-page navigation is the usual failure and it belongs to the framework rather than to Sanity.

  2. 02

    A headless stack diagnosed at the wrong layer

    Route changes not tracked, identifiers lost between pages — these are front-end framework problems that get filed against the CMS because that is the name everyone knows.

  3. 03

    The install that erases the campaign

    Someone clicks a paid ad on the mobile web, hits the app store, installs, and opens the app as a brand new anonymous user. Without deferred deep linking that campaign produced an organic install, and the ad account shows nothing for a conversion it genuinely caused.

  4. 04

    Nothing reconciles afterwards

    Branch shows the attributed link and campaign on the event in its dashboard. Check that the install carries a link click rather than showing as organic, which is the failure this product exists to prevent.

Sanity → Branch · the fix

What working looks like — Sanity → Branch

  • The Branch link click identifier and the deferred deep link payload on every conversion

  • Conversions arriving in Branch

    The event is attributed to the originating link and campaign, and forwarded to any configured downstream partners.

  • Reconciled against the source

Sanity → Branch · architecture

How Sanity and Branch actually connect

  1. 1

    Sanity holds the truth

    Sanity's real-time content APIs make it excellent at what it does and irrelevant to conversion measurement. Establishing that early saves the client money.

  2. 2

    Branch needs a click to match

    Branch needs the link click context matched to the app open, plus the event and its revenue. Without the deferred deep link payload there is nothing to join the install to.

  3. 3

    The identifier is the bridge

    The Branch link click identifier and the deferred deep link payload, captured at the visit and carried into the front-end conversion, not a Sanity record.

  4. 4

    The event source decides reliability

    Send from wherever the money is recorded, not from the content layer.

  5. 5

    Deduplication at the destination

    Branch deduplicates on the event identifier you supply. Firing a purchase from both the SDK and your server without a shared identifier double-counts, and Branch forwards to downstream partners, so the duplicate propagates.

Sanity → Branch · normal or broken

Working vs. broken, side by side — Sanity → Branch

Normal, not a fault

  • The Branch link click identifier and the deferred deep link payload present on the conversion

  • Sent from your commerce or CRM system

  • Deduplicated correctly

    Branch deduplicates on the event identifier you supply. Firing a purchase from both the SDK and your server without a shared identifier double-counts, and Branch forwards to downstream partners, so the duplicate propagates.

  • Reconciles with the source

Actually broken

  • The Branch link click identifier and the deferred deep link payload missing on most records

    The front-end application does the routing, the caching and the identifier capture. Single-page navigation is the usual failure and it belongs to the framework rather than to Sanity.

  • Sent from the browser

    Route changes not tracked, identifiers lost between pages — these are front-end framework problems that get filed against the CMS because that is the name everyone knows.

  • Counted twice, or not at all

    Someone clicks a paid ad on the mobile web, hits the app store, installs, and opens the app as a brand new anonymous user. Without deferred deep linking that campaign produced an organic install, and the ad account shows nothing for a conversion it genuinely caused.

  • Nobody has reconciled it

Sanity → Branch · diagnose

Diagnostic order — Sanity → Branch

  1. 01

    Count conversions carrying the Branch link click identifier and the deferred deep link payload

  2. 02

    Follow one real conversion end to end

  3. 03

    Identify the front-end framework, not the CMS

    The routing behaviour that breaks tracking belongs to Next.js, Nuxt or whatever renders the site.

  4. 04

    Measure your organic install share and ask whether it is plausible

    An implausibly large organic share is usually broken attribution rather than genuine word of mouth.

  5. 05

    Read the match rate, not the success message

    Branch shows the attributed link and campaign on the event in its dashboard. Check that the install carries a link click rather than showing as organic, which is the failure this product exists to prevent.

Sanity → Branch · prove

How it gets proven — Sanity → Branch

Source of truth

Your commerce, CRM or billing system — Sanity has no orders and no customers.

  • The Branch link click identifier and the deferred deep link payload confirmed present on a live conversion.
  • Attributed installs and in-app purchases reconciled against your own user records, with the unattributed share stated.
  • The conversion confirmed sourced from the commerce system, with front-end routing verified separately.

Sanity → Branch · free audit

What we check in the free audit

  • Count conversions carrying the Branch link click identifier and the deferred deep link payload
  • Follow one real conversion end to end
  • Identify the front-end framework, not the CMS
  • Measure your organic install share and ask whether it is plausible
  • Read the match rate, not the success message

Checked against

Your commerce, CRM or billing system — Sanity has no orders and no customers.

Get my free conversion tracking audit

Free30 minutesNo obligation

Sanity → Branch · when not to buy

When you don't need this — Sanity → Branch

  • Measure identifier coverage yourself first — pull your last hundred conversions and count how many carry the Branch link click identifier and the deferred deep link payload.
  • There is no Sanity-specific build. Fix the front end and the commerce integration; the CMS is not in the path.
  • If you have no app, or no web surface driving app installs, there is no seam here to bridge and the integration solves nothing.

Sanity → Branch · what we deliver

What gets built — Sanity → Branch

  • Identifier capture into Sanity

    Capture and persist the identifier server-side in the front-end application, then carry it into the system that records the sale.

  • Event source: your commerce or CRM system

    Send from wherever the money is recorded, not from the content layer.

  • Dispatch to Branch

    The Branch server-to-server events API, posted from your backend with the user identity and event data.

  • Reversals where they exist

    Handled by the commerce system.

Written guarantee

95%+ tracking accuracy

Measured against Your commerce, CRM or billing system — Sanity has no orders and no customers.. Miss it and we keep working at no cost.

Get my free conversion tracking audit

From $400 · See packages

FAQ

Sanity → Branch questions, answered

Either at render time in the front end or from a publish webhook calling Branch's API. If you write the link back to the document, filter the webhook so the write does not retrigger it.

Free · 30 min

Get Sanity and Branch joined properly

Free30 minutesNo obligation