Skip to main content
Sanity → MetaIntegration guide

Connecting Sanity to Meta Conversions API

Sanity is a headless content platform, which means like every headless CMS it holds no commercial record and the tracking question lives elsewhere. Meta's pixel loses a large share of conversions to Safari, ad blockers and iOS, and the Conversions API exists because of it. The join between them succeeds or fails on one thing: whether the fbc and fbp values reaches the front-end conversion, not a Sanity record before the conversion happens, because Meta can only match a conversion it can tie back to a click it recognizes.

Free30 minutesNo obligation

Specific to this pair

Sanity sites to Meta CAPI: fix the front end, send from commerce

Read fbclid in front-end middleware on the first request and set _fbc as a first-party server cookie, since the pixel may load after the parameter is gone. Send purchases to the Conversions API from commerce with an event_id shared with the pixel, avoid doubled PageView on route changes, and disable tracking in Sanity preview.

Meta's _fbc cookie is set by the pixel when it sees fbclid in the URL. On a JavaScript-heavy front end with a consent banner, the pixel may load after a route change has already removed fbclid from the address bar, and _fbc is never written. The fix lives in the front end, not Sanity: read fbclid on the first server request, in middleware, and set _fbc as a first-party cookie from your own server, which also avoids Safari's short lifetime for script-set cookies.

Purchases go to the Conversions API from the commerce system, with an event_id the browser pixel also uses, so the checkout has to receive that ID from the front end. Before adding manual PageView calls on route changes, check whether the pixel is already recording history changes on its own; doing both doubles PageView. Content-driven ViewContent events can carry the Sanity document slug, which helps when building audiences from article readers.

As with any Sanity site, editors' preview sessions load the real front end. If the pixel fires in Sanity's visual editing or draft preview, Meta builds audiences that include your own team. Disable the pixel and the server PageView path in preview mode.

Sanity → Meta · what breaks

Why this join usually fails — Sanity → Meta

  1. 01

    The fbc and fbp values 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

    Double counting from broken deduplication

    Server and browser both fire, the event_id does not match, and Meta counts two purchases. Reported ROAS goes up, the business does not, and it can run for months before anyone reconciles against the store.

  4. 04

    Nothing reconciles afterwards

    Events Manager shows received events, the deduplication state and an Event Match Quality score per event. Events arriving is not the test — deduplicated, well-matched events arriving is. Compare Meta's reported purchases against your store's order count for the same window.

Sanity → Meta · the fix

What working looks like — Sanity → Meta

  • The fbc and fbp values on every conversion

  • Conversions arriving in Meta

    Events appear in Events Manager with an Event Match Quality score, deduplicated against the pixel, and become usable for optimization and attribution.

  • Reconciled against the source

Sanity → Meta · architecture

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

    Meta Conversions API needs a click to match

    Meta matches server events to people using whatever identifiers you send, hashed with SHA-256 where required. There is no single mandatory key, which is why quality varies so much between implementations — a poorly matched event is accepted, reported, and worth much less than it appears.

  3. 3

    The identifier is the bridge

    The fbc and fbp values, 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

    Meta deduplicates on the pair of event_name and event_id. The browser pixel and the server event must send the same event_id for the same conversion, within the deduplication window. Get this wrong and every purchase counts twice — which is by far the most common Conversions API failure and it inflates reported ROAS rather than reducing it.

Sanity → Meta · normal or broken

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

Normal, not a fault

  • The fbc and fbp values present on the conversion

  • Sent from your commerce or CRM system

  • Deduplicated correctly

    Meta deduplicates on the pair of event_name and event_id. The browser pixel and the server event must send the same event_id for the same conversion, within the deduplication window. Get this wrong and every purchase counts twice — which is by far the most common Conversions API failure and it inflates reported ROAS rather than reducing it.

  • Reconciles with the source

Actually broken

  • The fbc and fbp values 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

    Server and browser both fire, the event_id does not match, and Meta counts two purchases. Reported ROAS goes up, the business does not, and it can run for months before anyone reconciles against the store.

  • Nobody has reconciled it

Sanity → Meta · diagnose

Diagnostic order — Sanity → Meta

  1. 01

    Count conversions carrying the fbc and fbp values

  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

    Read Event Match Quality and the deduplication indicator

    In Events Manager, open the event and check both. A low match quality means weak identifiers; a missing deduplication indicator means your event_id pairing is broken.

  5. 05

    Read the match rate, not the success message

    Events Manager shows received events, the deduplication state and an Event Match Quality score per event. Events arriving is not the test — deduplicated, well-matched events arriving is. Compare Meta's reported purchases against your store's order count for the same window.

Sanity → Meta · prove

How it gets proven — Sanity → Meta

Source of truth

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

  • The fbc and fbp values confirmed present on a live conversion.
  • Deduplication confirmed in Events Manager on a real purchase, with the browser and server events visibly paired rather than counted twice.
  • The conversion confirmed sourced from the commerce system, with front-end routing verified separately.

Sanity → Meta · free audit

What we check in the free audit

  • Count conversions carrying the fbc and fbp values
  • Follow one real conversion end to end
  • Identify the front-end framework, not the CMS
  • Read Event Match Quality and the deduplication indicator
  • 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 → Meta · when not to buy

When you don't need this — Sanity → Meta

  • Measure identifier coverage yourself first — pull your last hundred conversions and count how many carry the fbc and fbp values.
  • There is no Sanity-specific build. Fix the front end and the commerce integration; the CMS is not in the path.
  • If you are not running Meta ads at meaningful spend, the Conversions API is effort without payoff. It earns its cost when the optimization signal is worth improving.

Sanity → Meta · what we deliver

What gets built — Sanity → Meta

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

    Server-side events to the Conversions API with the event_id matched to the pixel, action_source set correctly, and customer data hashed before it leaves your infrastructure.

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

The pixel loaded after fbclid had already left the URL. Set _fbc server-side on the first request from the fbclid parameter.

Free · 30 min

Get Sanity and Meta joined properly

Free30 minutesNo obligation