Skip to main content
Sanity → SalesforceIntegration guide

Connecting Sanity to Salesforce

Sanity is a headless content platform, which means like every headless CMS it holds no commercial record and the tracking question lives elsewhere. Sending conversions into Salesforce rather than out of it is how marketing data reaches the place sales actually works. The join between them succeeds or fails on one thing: whether the Lead or Contact identity reaches the front-end conversion, not a Sanity record before the conversion happens, because Salesforce can only match a conversion it can tie back to a click it recognizes.

Free30 minutesNo obligation

Specific to this pair

Sanity forms to Salesforce: never store leads in the dataset

Do not store lead submissions in Sanity datasets. Post Sanity-built forms from a server route to the Salesforce API, or Web-to-Lead, with gclid, fbclid, li_fat_id, UTMs and landing page from a first-party cookie in custom Lead fields, plus the page's Sanity _id. Map click IDs through Lead conversion to the Opportunity for offline conversions.

B2B sites on Sanity often let editors build lead forms in the CMS: fields, labels, the thank-you message. That's fine. The mistake is storing submissions in Sanity too, as documents in the content dataset. Datasets can be public, read tokens end up in front-end builds, and lead data in a content store is personal data in the wrong place.

Submissions should go from the front end to Salesforce, through a server route that creates the Lead via the API, or through Web-to-Lead if the form is simple. Capture gclid, fbclid, li_fat_id, UTMs and landing page in the front end, keep them in a first-party cookie, and send them as hidden fields to custom Lead fields. Include the Sanity _id of the page the form sat on, so sales can see which content produced the lead.

Then check the Salesforce side: field-level security on the new fields for the integration user, validation rules that reject the record, and the Lead conversion mapping that carries click IDs to the Opportunity. Without that last mapping, the deal closes with no click ID and can't be sent back to ad platforms as an offline conversion. Test one submission all the way to a converted Opportunity.

Sanity → Salesforce · what breaks

Why this join usually fails — Sanity → Salesforce

  1. 01

    The Lead or Contact identity 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

    Writes that succeed and change nothing

    Field-level security, validation rules and required-field constraints can reject a write while the API reports success. Open the record and look rather than trusting the response.

  4. 04

    Nothing reconciles afterwards

    Check the record in Salesforce itself, not the API response. Then confirm the value survives Lead conversion onto the Contact, Account and Opportunity — the mapping is separate and is usually the thing that was missed.

Sanity → Salesforce · the fix

What working looks like — Sanity → Salesforce

  • The Lead or Contact identity on every conversion

  • Conversions arriving in Salesforce

    The marketing context appears on the record and flows into the opportunity, where sales and reporting can both use it.

  • Reconciled against the source

Sanity → Salesforce · architecture

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

    Salesforce needs a click to match

    Salesforce needs a resolvable record and a custom field to write to. Field-level security and validation rules can silently reject writes, which is a Salesforce-specific failure that returns success at the API level and changes nothing.

  3. 3

    The identifier is the bridge

    The Lead or Contact identity, 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

    Salesforce deduplicates according to whatever matching rules your org has configured, which vary enormously between instances. Duplicate Leads are the standard failure and merging them afterwards is manual work.

Sanity → Salesforce · normal or broken

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

Normal, not a fault

  • The Lead or Contact identity present on the conversion

  • Sent from your commerce or CRM system

  • Deduplicated correctly

    Salesforce deduplicates according to whatever matching rules your org has configured, which vary enormously between instances. Duplicate Leads are the standard failure and merging them afterwards is manual work.

  • Reconciles with the source

Actually broken

  • The Lead or Contact identity 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

    Field-level security, validation rules and required-field constraints can reject a write while the API reports success. Open the record and look rather than trusting the response.

  • Nobody has reconciled it

Sanity → Salesforce · diagnose

Diagnostic order — Sanity → Salesforce

  1. 01

    Count conversions carrying the Lead or Contact identity

  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

    Write a test value and open the record in the UI

    The API saying it worked and the field actually holding the value are different things in Salesforce more than anywhere else.

  5. 05

    Read the match rate, not the success message

    Check the record in Salesforce itself, not the API response. Then confirm the value survives Lead conversion onto the Contact, Account and Opportunity — the mapping is separate and is usually the thing that was missed.

Sanity → Salesforce · prove

How it gets proven — Sanity → Salesforce

Source of truth

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

  • The Lead or Contact identity confirmed present on a live conversion.
  • A test value confirmed present on the record in the UI, and confirmed to survive Lead conversion.
  • The conversion confirmed sourced from the commerce system, with front-end routing verified separately.

Sanity → Salesforce · free audit

What we check in the free audit

  • Count conversions carrying the Lead or Contact identity
  • Follow one real conversion end to end
  • Identify the front-end framework, not the CMS
  • Write a test value and open the record in the UI
  • 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 → Salesforce · when not to buy

When you don't need this — Sanity → Salesforce

  • Measure identifier coverage yourself first — pull your last hundred conversions and count how many carry the Lead or Contact identity.
  • There is no Sanity-specific build. Fix the front end and the commerce integration; the CMS is not in the path.
  • If your Salesforce org is administered by a team you cannot get time with, scope their availability before starting — this build is usually blocked on admin access rather than on the work.

Sanity → Salesforce · what we deliver

What gets built — Sanity → Salesforce

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

    API writes to the Lead or Contact record, or a platform event, carrying the marketing context as custom field values.

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

You can, but you shouldn't for leads. A content dataset isn't built for personal data and may be publicly readable; send submissions straight to Salesforce or your CRM.

Free · 30 min

Get Sanity and Salesforce joined properly

Free30 minutesNo obligation