Skip to main content
Sanity → Microsoft AdsIntegration guide

Connecting Sanity to Microsoft Ads

Sanity is a headless content platform, which means like every headless CMS it holds no commercial record and the tracking question lives elsewhere. Microsoft Ads reaches an older, higher-income, more desktop-weighted audience than Google, and it is routinely the cheapest qualified traffic a B2B advertiser can buy. The join between them succeeds or fails on one thing: whether the MSCLKID reaches the front-end conversion, not a Sanity record before the conversion happens, because Microsoft Ads can only match a conversion it can tie back to a click it recognizes.

Free30 minutesNo obligation

Specific to this pair

Sanity sites and Microsoft UET on client-side routing

Enable UET's automatic SPA tracking, or send page views on route change, so thank-you goals count. Capture the MSCLKID per request in middleware into a first-party cookie, carry it into the CRM lead or commerce order, and run the offline import from there. Never render click IDs into cached HTML, and confirm auto-tagging is on.

On a Sanity-backed front end, the UET tag sees the first page load and then nothing unless single-page tracking is switched on. Microsoft's UET tag has an option for automatic SPA tracking; check that it is enabled in your tag configuration, or send page views manually on route change. Destination-URL goals for thank-you pages silently undercount without it.

Capture the MSCLKID in the front end's middleware or server on the first request and set a first-party cookie, then carry it into whichever system records the sale, a CRM lead or a commerce order. The offline import runs from that system. Sanity holds no orders, so there is nothing to upload from the CMS itself.

Static generation adds a trap that only headless sites have. Pages built ahead of time or cached at the edge must never have the MSCLKID or any click identifier rendered into the HTML, or one visitor's identifier gets served to everyone who loads that cached page. Read identifiers per request in middleware or in the browser, never in the data-fetching step that builds the page from Sanity content. Then check one thing in the Microsoft account itself: auto-tagging, which is often off in accounts imported from Google.

Sanity → Microsoft Ads · what breaks

Why this join usually fails — Sanity → Microsoft Ads

  1. 01

    The MSCLKID 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

    Auto-tagging switched off

    Microsoft auto-tagging is frequently disabled in accounts that were set up quickly or imported from Google, and without it no MSCLKID arrives at all — so the entire offline import has nothing to match against and fails silently.

  4. 04

    Nothing reconciles afterwards

    Microsoft Ads reports offline conversion uploads with rows accepted and rejected. A successful upload is not a matched conversion — check that conversions actually appear against campaigns afterwards.

Sanity → Microsoft Ads · the fix

What working looks like — Sanity → Microsoft Ads

  • The MSCLKID on every conversion

  • Conversions arriving in Microsoft Ads

    Conversions appear against the campaign, ad group and keyword that produced the click, with the value you sent, and become usable for automated bidding.

  • Reconciled against the source

Sanity → Microsoft Ads · architecture

How Sanity and Microsoft Ads 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

    Microsoft Ads needs a click to match

    Microsoft matches uploaded conversions to clicks using the MSCLKID, and the conversion goal must be created as an offline conversion type. The click has to fall inside Microsoft's import window — verify the current limit in your account rather than assuming it matches Google's.

  3. 3

    The identifier is the bridge

    The MSCLKID, 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

    Microsoft deduplicates on the combination of click identifier, conversion name and conversion time. Uploading the same click against a second conversion goal counts twice, which is the usual cause of inflated numbers here.

Sanity → Microsoft Ads · normal or broken

Working vs. broken, side by side — Sanity → Microsoft Ads

Normal, not a fault

  • The MSCLKID present on the conversion

  • Sent from your commerce or CRM system

  • Deduplicated correctly

    Microsoft deduplicates on the combination of click identifier, conversion name and conversion time. Uploading the same click against a second conversion goal counts twice, which is the usual cause of inflated numbers here.

  • Reconciles with the source

Actually broken

  • The MSCLKID 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

    Microsoft auto-tagging is frequently disabled in accounts that were set up quickly or imported from Google, and without it no MSCLKID arrives at all — so the entire offline import has nothing to match against and fails silently.

  • Nobody has reconciled it

Sanity → Microsoft Ads · diagnose

Diagnostic order — Sanity → Microsoft Ads

  1. 01

    Count conversions carrying the MSCLKID

  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

    Confirm auto-tagging is enabled and check the upload diagnostics

    One account setting decides whether any of this works. Then read the per-row errors on the upload rather than the success count.

  5. 05

    Read the match rate, not the success message

    Microsoft Ads reports offline conversion uploads with rows accepted and rejected. A successful upload is not a matched conversion — check that conversions actually appear against campaigns afterwards.

Sanity → Microsoft Ads · prove

How it gets proven — Sanity → Microsoft Ads

Source of truth

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

  • The MSCLKID confirmed present on a live conversion.
  • Auto-tagging confirmed on, and the accepted count reconciled against conversions appearing in campaign reporting.
  • The conversion confirmed sourced from the commerce system, with front-end routing verified separately.

Sanity → Microsoft Ads · free audit

What we check in the free audit

  • Count conversions carrying the MSCLKID
  • Follow one real conversion end to end
  • Identify the front-end framework, not the CMS
  • Confirm auto-tagging is enabled and check the upload diagnostics
  • 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 → Microsoft Ads · when not to buy

When you don't need this — Sanity → Microsoft Ads

  • Measure identifier coverage yourself first — pull your last hundred conversions and count how many carry the MSCLKID.
  • 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 Microsoft Ads at meaningful spend, skip it — though for B2B the traffic is often cheaper and better qualified than people expect, which is worth testing before dismissing.

Sanity → Microsoft Ads · what we deliver

What gets built — Sanity → Microsoft Ads

  • 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 Microsoft Ads

    Offline conversion import through the Microsoft Advertising API or a scheduled upload.

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

Only if automatic SPA tracking is enabled in the UET tag or you send page views on each route change. Check your tag configuration.

Free · 30 min

Get Sanity and Microsoft Ads joined properly

Free30 minutesNo obligation