Microsoft Clarity Consent API v2
Keep session recordings, heatmaps and user behaviour tracking in Microsoft Clarity running — fully consent-aware, with CookieHub as your CMP.
Built-in CookieHub support · HTML and GTM compatible
Microsoft Clarityclarity consentv2analytics_Storagegrantedad_Storagedenied- Type
- Consent API
- Works with
- Microsoft Clarity
- Parameters
- analytics_Storage and ad_Storage
- Required in
- EEA, UK and Switzerland
- CookieHub support
- Built in, from 2.8.12
What the Clarity Consent API v2 actually does.
The Clarity Consent API v2 lets a website tell Microsoft Clarity what the visitor has agreed to — a necessity in privacy-first environments. Clarity reads two consent states, one for analytics storage and one for advertising storage, and adjusts its tracking to match.
Without valid consent, Clarity disables cookie-based tracking, session linking and cookie persistence for visitors in the EEA, the UK and Switzerland. With consent granted, full session tracking, heatmaps, funnels and analytics resume — so Clarity follows the visitor’s consent choices and you keep your insight into user behaviour.
CookieHub collects the visitor’s choice and passes it to Clarity from the CMP layer, so you don’t handle the logic or timing yourself.
- 01Page loadsclarity tag
- 02Clarity starts in no-consent modedenied by default
- 03Visitor makes a choicebanner
- 04CookieHub calls consentv2consent update
- 05Clarity sets cookies or stays cookielesstracking mode
From visitor choice to Microsoft Clarity.
Pick a visitor state to see the consent states CookieHub passes to Clarity.
The visitor has arrived and the banner is showing. Clarity waits in no-consent mode.
Microsoft Claritydefaultanalytics_Storagedeniedad_StoragedeniedThe visitor accepted analytics but not marketing.
Microsoft Clarityupdatedanalytics_Storagegrantedad_StoragedeniedThe visitor accepted both analytics and marketing.
Microsoft Clarityupdatedanalytics_Storagegrantedad_StoragegrantedThe visitor declined, or withdrew an earlier choice.
Microsoft Clarityupdatedanalytics_Storagedeniedad_StoragedeniedIllustrative signal behaviour for one configuration. Actual behaviour depends on the site’s consent configuration and the visitor’s region.
The two states Clarity listens for.
Every consentv2 call carries both parameters. CookieHub fills each one from a cookie category.
| Parameter | Purpose | CookieHub category | Example state |
|---|---|---|---|
| analytics_Storage | Analytics storage: Clarity’s cookies, session linking and returning-visitor recognition. | Analytics | granted |
| ad_Storage | Advertising storage: whether Clarity shares data with Microsoft Ads. | Marketing | denied |
What Clarity does in each state.
analytics_Storage decides whether Clarity can use cookies — the signal that keeps recordings, heatmaps and funnels connected.
analytics_Storage- granted
Full session tracking
- Clarity sets its cookies, such as _clck and _clsk.
- Page views are linked into sessions and returning visitors are recognised.
- Session recordings, heatmaps and funnels work as configured.
- denied
No-consent mode
- Clarity sets no cookies.
- Each page view gets its own ID, so sessions aren’t linked.
- Recordings, funnels and other cookie-based features may be limited.
ad_Storage works alongside it: granted lets Clarity share data with Microsoft Ads, denied shares none. If a visitor withdraws consent, Clarity deletes its cookies, ends the session and continues in no-consent mode.
Your Clarity consent solution, built in.
User-friendly and future-ready: CookieHub maps every choice to Clarity’s parameters across CMSs, Google Tag Manager or custom environments.
See how consent management worksClarity integration
settings → integrationsTurn on Clarity Consent API v2 under Integrations in your domain settings.
Category mapping
category → parameterAnalytics feeds analytics_Storage, Marketing feeds ad_Storage.
Region-aware banner
region rulesShow the banner where consent is required, such as the EEA, the UK and Switzerland.
Real-time updates
consent updateSignal Clarity again when the visitor changes or withdraws a choice.
Scanning and blocking
scan · blockScanning finds cookies on your site; supported services can be blocked automatically, others may need manual configuration. Don’t use automatic blocking with GTM.
Consent records
consent logKeep an audit log of consent decisions once consent records are enabled. Availability depends on your CookieHub plan.
Clarity consent stateexampleanalytics_Storagegrantedad_StoragedeniedHTML or GTM
html · gtmWorks with the CookieHub script in the page head or the CookieHub CMP template in GTM.
Set up the Clarity Consent API v2.
Three phases, from adding CookieHub to confirming the consent state Clarity holds.
- 01
Connect
Add CookieHub to the site, directly or through Google Tag Manager.
- 01Add the CookieHub script to the page head, or the CookieHub CMP template in GTM.
- 02Use CookieHub 2.8.12 or later.
- 02
Configure
Turn on consent in Clarity and the integration in CookieHub.
- 03Set your Clarity project to require cookie consent.
- 04Turn on Clarity Consent API v2 under Integrations in the Settings tab.
- 05Categorise Clarity’s cookies as analytics, not necessary.
- 06Save and publish.
- 03
Verify
Confirm that Clarity receives the expected state.
- 07Run Clarity’s consent check in the browser console.
- 08Decline, then confirm no _clck or _clsk cookie is set.
- 09Accept, then confirm analytics_Storage is granted.
Running Clarity through GTM?
Load CookieHub with its community template, and Clarity receives the consent state before it starts tracking.
- Add the CookieHub CMP tag from the Community Template Gallery.
- Enter your CookieHub domain code.
- Set the trigger to Consent Initialization – All Pages.
- Turn on Clarity Consent API v2 in CookieHub, then save and publish.
- Clarity trackinganalytics_Storage
- Microsoft Ads sharingad_Storage
- Other consent-aware tagsconsent state
Is the Clarity Consent API working on your site?
Check the consent state Clarity holds before and after the visitor chooses. Microsoft documents these checks for Clarity.
- 01
Console check
clarity('metadata', …)In the browser console, run clarity('metadata', (d, upgrade, consent) => { console.log('consentStatus:', consent); }, false, true, true) and read consentStatus before and after the visitor chooses.
- 02
Cookie check
_clck · _clskClear cookies, decline on the banner and confirm Clarity still runs but sets no _clck or _clsk cookie.
- 03
Project setting
clarity settingsConfirm your Clarity project requires cookie consent — the Consent API only takes effect when it does.
Works with Clarity and the tools around it.
CookieHub passes the consent state Clarity reads, on its own or alongside your Microsoft and Google tags.
Microsoft Clarityconsentv2- Microsoft Advertisingad_Storage
- Microsoft UETuet consent mode
Google Tag Managercookiehub template
Listed by Microsoft as a supported CMP.
Microsoft’s Clarity documentation lists CookieHub among the consent management platforms that pass consent to Clarity automatically. CookieHub supports the Clarity Consent API v2 from version 2.8.12 and maintains compatibility as Clarity and privacy rules evolve.
Official Microsoft documentation.
Last reviewedOctober 2026- Clarity Cookie Consent API - ConsentV2The consentv2 syntax, its two parameters and what Clarity does when a visitor rejects cookies.learn.microsoft.com
- Consent ModeHow to make a Clarity project wait for consent, and how to check it in the browser console.learn.microsoft.com
- Consent ManagementClarity’s consent types, what each state changes and the enforcement in the EEA, the UK and Switzerland.learn.microsoft.com
- Cookie Consent Management Platforms (CMPs)The consent management platforms that pass consent to Clarity automatically, CookieHub among them.learn.microsoft.com
- Microsoft Clarity Consent API v2 (CookieHub)CookieHub’s setup guide for HTML and Google Tag Manager, with the category mapping.docs.cookiehub.com
FAQ about the Clarity Consent API v2.
The Clarity Consent API v2 is Microsoft’s JavaScript consent interface for Clarity. It replaces the older window.clarity('consent') API and passes separate consent states for advertising and analytics — ad_Storage and analytics_Storage — through window.clarity('consentv2', …).
Since 31 October 2025, Clarity enforces consent signals for traffic from the EEA, the UK and Switzerland. Without a valid consentv2 signal, Clarity runs without cookies for those visitors, and features such as session linking, funnels and recordings may be limited.
Clarity listens for the window.clarity('consentv2', …) call with the visitor’s consent states. CookieHub makes that call when the visitor interacts with the banner, and Clarity adjusts its tracking: it either enables cookies, session linking and full analytics, or keeps them off.
Any website that uses Microsoft Clarity and reaches visitors in the EEA, the UK or Switzerland needs it to keep full Clarity functionality. Without it, Clarity still runs, but session linking and advanced features degrade.
It preserves session continuity, heatmaps, funnels and detailed user journeys for visitors who consent, in a privacy-aware way. The two states are separate, so analytics can still run when a visitor withholds advertising consent.
Mainly the EEA, the UK and Switzerland, where explicit prior consent is required for non-essential cookies such as analytics and advertising storage. Clarity has enforced this there since 31 October 2025. Elsewhere, a consent-aware setup still improves transparency and future-proofs your analytics.
No. The Clarity Consent API v2 aligns Clarity’s behaviour with consent signals, but compliance depends on your overall consent strategy, records, legal notices and user choices. CookieHub provides the infrastructure — banner, scanning, blocking and, depending on your plan, consent records — while you manage policy, disclosures and governance.
Clarity sets no cookies and gives each page view its own ID, so page views aren’t linked into sessions. If a visitor withdraws earlier consent, Clarity deletes its existing cookies, ends the session and continues in no-consent mode.
Yes, from version 2.8.12. Turn on Clarity Consent API v2 under Integrations in your domain settings and CookieHub sends the signals automatically, mapping Analytics to analytics_Storage and Marketing to ad_Storage. Versions 2.8.8 to 2.8.11 support only Clarity’s original consent API.
Run clarity('metadata', …) in the browser console with the callback Microsoft documents to log consentStatus before and after a choice, and check that no _clck or _clsk cookie is set after a visitor declines. Your Clarity project must also be set to require cookie consent.
If you use Microsoft Clarity for visitors in regions with privacy laws, such as the EEA, the UK and Switzerland, yes — to keep full tracking features. If you don’t have visitors from those regions, a consent-aware approach is still recommended.
Disclaimer
This page describes how consent signals are passed to Microsoft Clarity. It is technical guidance, not legal advice, and it does not describe every possible configuration — which consent model applies to your visitors depends on the regulations relevant to your site.
Clear insights that respect consent.
Connect CookieHub to Microsoft Clarity to respect user consent while keeping powerful behaviour insights — see how visitors use your site within the limits of the consent they give.
- 14-day trial
- No card required
