Skip to main content
Sanity → AmplitudeIntegration guide

Connecting Sanity to Amplitude

Sanity is a headless content platform, which means like every headless CMS it holds no commercial record and the tracking question lives elsewhere. Amplitude is built around behavioural cohorts, which makes the identity resolution and the event taxonomy load-bearing in a way they never are for an ad pixel. The join between them succeeds or fails on one thing: whether the user ID and device ID pair reaches the front-end conversion, not a Sanity record before the conversion happens, because Amplitude can only match a conversion it can tie back to a click it recognizes.

Free30 minutesNo obligation

Specific to this pair

Sanity content in Amplitude: cohorts by document, not URL

Add the Sanity document _id and _type as properties on Amplitude page view events, keyed on _id rather than editable slugs, and fire page views on single-page route changes. Strip drafts. prefixes or disable tracking in preview. Revenue comes server-side from commerce or billing with the same user or device ID, so content cohorts connect to purchases.

Amplitude can tell you something Sanity can't: whether people who read particular content go on to activate or buy. To build cohorts on that, page view events need content identity attached. Add the Sanity document _id and _type as event properties when the front end renders a page, next to the URL.

Use the _id rather than the slug as the key. Slugs get edited, and a renamed article splits into two rows in every chart, while the _id stays the same for the life of the document. Watch for draft IDs, which carry a drafts. prefix in Sanity, leaking into events from preview mode; turn tracking off in preview or strip the prefix before sending. Route changes in a single-page front end must fire their own page view, or every session looks like a single page.

Revenue still comes from the commerce or billing system, sent server-side with the same user or device ID the browser SDK used, and with price and quantity populated. The content properties only connect to that revenue if identity is consistent between front end and backend, which is a front-end framework job. Sanity's part is a stable ID; nothing in Sanity itself needs to change.

Sanity → Amplitude · what breaks

Why this join usually fails — Sanity → Amplitude

  1. 01

    The user ID and device ID pair 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

    Revenue events that carry no revenue

    Amplitude will happily accept a purchase event with no price field. The event count looks correct, the funnel looks correct, and the revenue reporting stays at zero — which people usually discover a quarter later when someone asks what a cohort is worth.

  4. 04

    Nothing reconciles afterwards

    Amplitude shows the event in the user's activity stream with its properties expanded. Read the properties, because an event that arrives without its revenue fields still looks like a success.

Sanity → Amplitude · the fix

What working looks like — Sanity → Amplitude

  • The user ID and device ID pair on every conversion

  • Conversions arriving in Amplitude

    The event lands on the user, joins their behavioural history, and becomes available for cohorts, funnels and retention.

  • Reconciled against the source

Sanity → Amplitude · architecture

How Sanity and Amplitude 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

    Amplitude needs a click to match

    Amplitude needs a device or user identifier, an event type and its properties. Revenue events need the price and quantity fields specifically, or the revenue reporting stays empty while events flow normally.

  3. 3

    The identifier is the bridge

    The user ID and device ID pair, 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

    Amplitude deduplicates on insert_id. Omit it and a retried batch is counted twice, which shows up as a phantom spike that someone will eventually build a hypothesis on.

Sanity → Amplitude · normal or broken

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

Normal, not a fault

  • The user ID and device ID pair present on the conversion

  • Sent from your commerce or CRM system

  • Deduplicated correctly

    Amplitude deduplicates on insert_id. Omit it and a retried batch is counted twice, which shows up as a phantom spike that someone will eventually build a hypothesis on.

  • Reconciles with the source

Actually broken

  • The user ID and device ID pair 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

    Amplitude will happily accept a purchase event with no price field. The event count looks correct, the funnel looks correct, and the revenue reporting stays at zero — which people usually discover a quarter later when someone asks what a cohort is worth.

  • Nobody has reconciled it

Sanity → Amplitude · diagnose

Diagnostic order — Sanity → Amplitude

  1. 01

    Count conversions carrying the user ID and device ID pair

  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

    Check a purchase event for the price and quantity fields specifically

    Not whether the event arrived — whether the revenue fields are populated, in the exact names Amplitude expects.

  5. 05

    Read the match rate, not the success message

    Amplitude shows the event in the user's activity stream with its properties expanded. Read the properties, because an event that arrives without its revenue fields still looks like a success.

Sanity → Amplitude · prove

How it gets proven — Sanity → Amplitude

Source of truth

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

  • The user ID and device ID pair confirmed present on a live conversion.
  • Revenue reconciled per transaction against your billing system, with identity merge behaviour verified across signup.
  • The conversion confirmed sourced from the commerce system, with front-end routing verified separately.

Sanity → Amplitude · free audit

What we check in the free audit

  • Count conversions carrying the user ID and device ID pair
  • Follow one real conversion end to end
  • Identify the front-end framework, not the CMS
  • Check a purchase event for the price and quantity fields specifically
  • 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 → Amplitude · when not to buy

When you don't need this — Sanity → Amplitude

  • Measure identifier coverage yourself first — pull your last hundred conversions and count how many carry the user ID and device ID pair.
  • There is no Sanity-specific build. Fix the front end and the commerce integration; the CMS is not in the path.
  • If nobody is building cohorts or retention analysis, this is a large amount of instrumentation for reporting a dashboard already gives you.

Sanity → Amplitude · what we deliver

What gets built — Sanity → Amplitude

  • 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 Amplitude

    The Amplitude HTTP V2 API, posted server-side with the identity, event type and properties.

  • 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 → Amplitude questions, answered

Send the Sanity document _id and _type as properties on page view events from your front end, then build cohorts of users who viewed specific documents or types. Join outcomes on the same user ID.

Free · 30 min

Get Sanity and Amplitude joined properly

Free30 minutesNo obligation