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
- 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.
- 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.
- 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.
- 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
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
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
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
The event source decides reliability
Send from wherever the money is recorded, not from the content layer.
- 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
- 01
Count conversions carrying the fbc and fbp values
- 02
Follow one real conversion end to end
- 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.
- 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.
- 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.
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.
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.
Sanity has no orders or customers, so there is nothing to send from it. Purchases go from your commerce system; Sanity only shapes the pages.
Almost always because the fbc and fbp values never reached the front-end conversion, not a Sanity record. 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. Measure coverage before debugging the dispatch.
Two things. The _fbc cookie, derived from the fbclid parameter on the landing URL in the format fb.1.<timestamp>.<fbclid>, is the click identifier. The _fbp cookie is the browser identifier. Beyond those, Meta matches on hashed customer information — email, phone, name, city, country — and every additional field raises the Event Match Quality score. Unlike Google, Meta does not need a click ID at all if the customer data is good, but match quality drops noticeably without it.
Your commerce or CRM system. Send from wherever the money is recorded, not from the content layer.
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.
More on Sanity → Meta
- Meta · Lead → booked callHow to track lead to booked call for Meta Ads
- Meta · Booked call → closed wonHow to track booked call to closed won for Meta Ads
- Meta · Free trial → paidHow to track free trial to paid for Meta Ads
RELATED GUIDES
Where Sanity → Meta fits in the rest of your tracking
- Meta · Local servicesMeta Ads conversion tracking for local service businesses
- Meta · B2BMeta Ads conversion tracking for B2B companies
- Meta × CRM DealsHow to reconcile Meta Ads against your CRM's closed-won deals
- Meta · Comparison page → demoHow to track comparison page visit to demo request for Meta Ads
- Concrete CMS → MetaConnecting Concrete CMS to Meta Conversions API
- Sanity → SnapchatConnecting Sanity to Snapchat
- Local servicesConversion tracking for local businesses, where most conversions bypass the website
- Statamic → MetaConnecting Statamic to Meta Conversions API
Free · 30 min
Get Sanity and Meta joined properly
Free30 minutesNo obligation
