Connecting Sanity to BigQuery
Sanity is a headless content platform, which means like every headless CMS it holds no commercial record and the tracking question lives elsewhere. BigQuery has no attribution model, no deduplication rules and no opinion about your data — which makes it the only destination on this site where every number is exactly as good as the query that produced it. The join between them succeeds or fails on one thing: whether whatever join key you decide on reaches the front-end conversion, not a Sanity record before the conversion happens, because BigQuery can only match a conversion it can tie back to a click it recognizes.
Free30 minutesNo obligation
Specific to this pair
Sanity content as a BigQuery dimension table, keyed on _id
Load Sanity into BigQuery as a dimension table of documents with _id, _type, title, slug, author, publish date and taxonomy, via publish webhooks or a nightly export, excluding drafts. Send the _id on front-end page views and join on it, not URL or title, keeping slug history. Conversions load from commerce or CRM with click IDs.
Sanity belongs in BigQuery as a dimension table, not as a source of conversions. Export documents with _id, _type, title, slug, author, publish date and any taxonomy fields, so analytics events and orders can be grouped by content attributes no URL carries. Sanity's GROQ-powered webhooks can upsert a row whenever a document is published, or a scheduled export can rebuild the table nightly.
The join key is the document _id, sent as a property on page views from the front end, typically into the GA4 BigQuery export or your own event table. Joining on URL breaks every time an editor changes a slug, and joining on title breaks at the first duplicate. Exclude drafts (IDs with the drafts. prefix) from the dimension table, and keep a history of slug changes so older events that only recorded URLs can still be mapped.
Conversions come from your commerce or CRM system, loaded with the click IDs captured on the landing page. With both in BigQuery, a first-touch query from order to session to landing document shows which content brings in customers rather than just traffic. Keep expectations modest: content usually sits early in a journey, and last-click platforms will credit almost none of it.
Sanity → BigQuery · what breaks
Why this join usually fails — Sanity → BigQuery
- 01
Whatever join key you decide on 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
The warehouse quietly disagreeing with every platform
This is not a bug — it is the point. Your warehouse counts orders; Google counts click-attributed conversions in its window; Meta counts differently again. When the four numbers differ, the warehouse is usually right about revenue and wrong about attribution, and knowing which question you are answering is the whole skill.
- 04
Nothing reconciles afterwards
BigQuery will not tell you anything is wrong. Verify by querying the table directly against your source system's own totals, and check for duplicate rows on the join key before trusting any aggregate.
Sanity → BigQuery · the fix
What working looks like — Sanity → BigQuery
Whatever join key you decide on on every conversion
Conversions arriving in BigQuery
The row lands in a table you own, joinable to every other table you own, with no window and no expiry.
Reconciled against the source
Sanity → BigQuery · architecture
How Sanity and BigQuery 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
BigQuery needs a click to match
BigQuery needs a schema and consistent types. The failure mode is not rejection, it is silent divergence: a column that arrives as a string in one load and an integer in the next, or a timestamp in the wrong zone, which produces answers that look plausible and are not.
- 3
The identifier is the bridge
Whatever join key you decide on, 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
Nothing deduplicates for you. Streaming inserts are at-least-once, so a retried load can create duplicate rows, and the only protection is a deduplication step you write and actually run.
Sanity → BigQuery · normal or broken
Working vs. broken, side by side — Sanity → BigQuery
Normal, not a fault
Whatever join key you decide on present on the conversion
Sent from your commerce or CRM system
Deduplicated correctly
Nothing deduplicates for you. Streaming inserts are at-least-once, so a retried load can create duplicate rows, and the only protection is a deduplication step you write and actually run.
Reconciles with the source
Actually broken
Whatever join key you decide on 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
This is not a bug — it is the point. Your warehouse counts orders; Google counts click-attributed conversions in its window; Meta counts differently again. When the four numbers differ, the warehouse is usually right about revenue and wrong about attribution, and knowing which question you are answering is the whole skill.
Nobody has reconciled it
Sanity → BigQuery · diagnose
Diagnostic order — Sanity → BigQuery
- 01
Count conversions carrying whatever join key you decide on
- 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
Reconcile warehouse order counts against each platform for one closed window
The gaps localize the problem: a gap against all platforms is a collection issue, a gap against one is that platform's window or matching.
- 05
Read the match rate, not the success message
BigQuery will not tell you anything is wrong. Verify by querying the table directly against your source system's own totals, and check for duplicate rows on the join key before trusting any aggregate.
Sanity → BigQuery · prove
How it gets proven — Sanity → BigQuery
Source of truth
Your commerce, CRM or billing system — Sanity has no orders and no customers.
- Whatever join key you decide on confirmed present on a live conversion.
- Warehouse order counts and revenue reconciled against the source system for a fully closed window, with duplicates checked on the join key.
- The conversion confirmed sourced from the commerce system, with front-end routing verified separately.
Sanity → BigQuery · free audit
What we check in the free audit
- Count conversions carrying whatever join key you decide on
- Follow one real conversion end to end
- Identify the front-end framework, not the CMS
- Reconcile warehouse order counts against each platform for one closed window
- 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 → BigQuery · when not to buy
When you don't need this — Sanity → BigQuery
- Measure identifier coverage yourself first — pull your last hundred conversions and count how many carry whatever join key you decide on.
- There is no Sanity-specific build. Fix the front end and the commerce integration; the CMS is not in the path.
- If you have one store and one ad platform, a warehouse is infrastructure you will maintain for a reconciliation you could do in a spreadsheet.
Sanity → BigQuery · what we deliver
What gets built — Sanity → BigQuery
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 BigQuery
Streaming inserts or scheduled batch loads from your order system, with the raw event retained alongside whatever you derive from it.
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 → BigQuery questions, answered
Use Sanity's webhooks to send document changes to an endpoint that writes to BigQuery, or run a scheduled GROQ query and load the result. Keep _id as the key and exclude drafts.
Send the document _id as an event parameter from your front end so it appears in the GA4 export, then join to the Sanity table on that ID. URL joins break when slugs change.
Almost always because whatever join key you decide on 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.
There is no vendor identifier here. You choose the key — order ID, user ID, click identifier, hashed email — and you live with the consequences. That is the whole appeal and the whole risk: nothing is standardised for you and nothing is silently wrong in a vendor's favour either.
Your commerce or CRM system. Send from wherever the money is recorded, not from the content layer.
BigQuery will not tell you anything is wrong. Verify by querying the table directly against your source system's own totals, and check for duplicate rows on the join key before trusting any aggregate.
More on Sanity → BigQuery
- Sanity → Google AdsConnecting Sanity to Google Ads
- Sanity → MetaConnecting Sanity to Meta Conversions API
- Sanity → GA4Connecting Sanity to GA4
RELATED GUIDES
Where Sanity → BigQuery fits in the rest of your tracking
- Concrete CMS → BigQueryConnecting Concrete CMS to BigQuery
- Drupal Commerce → BigQueryConnecting Drupal Commerce to BigQuery
- Contentful → BigQueryConnecting Contentful to BigQuery
- Sanity → SnowflakeConnecting Sanity to Snowflake
- Sanity → SegmentConnecting Sanity to Segment
- Local servicesConversion tracking for local businesses, where most conversions bypass the website
- Sitecore → BigQueryConnecting Sitecore to BigQuery
- Statamic → BigQueryConnecting Statamic to BigQuery
Free · 30 min
Get Sanity and BigQuery joined properly
Free30 minutesNo obligation
