Skip to main content

Consent

15 min read

Microsoft Clarity Consent API Explained

By Shreya September 11, 2025

Microsoft Clarity Consent API Explained

Understanding how people use your website is essential for improving user experience and making better business decisions. But in today’s privacy-focused world, gaining insights must go hand-in-hand with earning users’ trust. That’s why Microsoft Clarity offers a Consent API—to help you stay compliant with data privacy laws like the GDPR, UK GDPR, and ePrivacy Directive.

This guide walks you through what the Microsoft Clarity Consent API is, why it matters for your business, how it works, and how to implement it without needing to write code.

Analytics and consent: The data privacy connection

The legal landscape around cookies and tracking has shifted significantly over the last decade. Regulations such as the General Data Protection Regulation (GDPR), UK GDPR, and ePrivacy Directive require that users opt in before cookies are set. That includes cookies used for analytics.

What does this mean for website owners?

If you’re using a tool like Microsoft Clarity, you must:

  • Clearly inform users about what data you collect.
  • Obtain explicit consent before setting cookies.
  • Stop tracking if a user declines or withdraws consent.

Clarity’s default script begins tracking immediately upon loading. Without safeguards in place, this behaviour could violate privacy laws. That’s where the Consent API becomes essential.

Consent, as defined in Article 4(11) of the GDPR, must be “freely given, specific, informed and unambiguous.” Moreover, Recital 32 clarifies that silence, pre-ticked boxes, or inactivity do not constitute valid consent. Therefore, activating Clarity without an affirmative action from the user can result in non-compliance.

What is the Microsoft Clarity Consent API?

The Clarity Consent API is a way to tell Microsoft Clarity when it is allowed to start tracking a visitor. By default, Clarity begins collecting data immediately after the script loads—but this can violate privacy laws if you haven’t obtained user consent.

Instead of assuming consent, the Consent API waits for a signal from your cookie banner or Consent Management Platform (CMP). Only after a user accepts analytics cookies does Clarity begin tracking.

What it means for your website:

  • Before consent: No cookies are set, and no session data is collected.
  • After consent: Full tracking begins, including session replays and heatmaps.
  • If consent is withdrawn: Tracking must stop, and cookies must be removed or disabled.

This approach ensures that your site follows privacy-by-design principles and avoids non-compliance.

Why does Clarity Consent API matter?

As digital privacy laws continue to evolve, enforcement is becoming stricter. In regions like the EEA, UK, and Switzerland, user consent is mandatory before setting non-essential cookies, including those used for analytics.

Starting 31 October, 2025, Microsoft Clarity will enforce consent signal requirements in these regions.

 

Without a valid consent signal:

  • Clarity will not fully function: features such as session recordings, heatmaps, and funnel tracking will be disabled.
  • Consent API implementation becomes mandatory to continue using Clarity’s analytics.
  • Compliance must be demonstrable during audits to meet regulatory standards.

This requirement aligns with key GDPR principles:

The importance of using the Consent API, however, goes beyond legal compliance. It also helps build long-term trust with your users.

According to Cisco’s 2025 Data Privacy Benchmark Study,

  • 96% of organisations report that the business benefits from investing in privacy are greater than the costs
  • 95% of users say they won’t buy from a company they don’t trust with their data
  • 76% say they won’t share sensitive data unless confident it will be handled responsibly

Using the Consent API shows that:

  • You prioritise user privacy
  • You’re transparent about data collection
  • Compliance is built into your strategy, not treated as an afterthought

It’s not just about following the rules—it’s about fostering digital integrity and earning user trust.

Do you need to update the existing Clarity setup?

If you serve users in the EEA, UK, or Switzerland, you must update your Clarity implementation to include the Consent API to remain compliant and retain analytics functionality.

To enable tracking only after user consent, use the following call:



window.clarity('consentv2', {
  ad_Storage: "granted",
  analytics_Storage: "granted"
});

The previous API call window.clarity('consent') is now deprecated. All new implementations must use the Consent v2 method, which allows you to pass consent separately for ads and analytics.

For more examples, click here.

This ensures that Clarity starts setting cookies and collecting session data only after the user has actively agreed, helping you stay compliant with GDPR and ePrivacy regulations.

How does the Microsoft Clarity consent API work?

The Microsoft Clarity Consent API is designed to help websites respect user privacy by making sure tracking only happens when users give their permission. Here’s a step-by-step overview of how it works:

1. User visits your website

When someone lands on your site, they usually see a cookie consent banner or pop-up. This is managed by your consent management platform (CMP), which asks the user if they agree to different types of cookies and tracking, including Microsoft Clarity.

2. User makes a choice

The visitor can either accept or decline the use of analytics cookies. This choice is very important because privacy laws in places like Europe require explicit consent before tracking can begin.

3. Your website communicates consent to Clarity

Once the user consents, your website uses the Clarity Consent API to inform Clarity that it’s okay to start tracking. This is done by running a simple command in your website’s code that tells Clarity “the user has agreed.”

4. Clarity starts tracking

After receiving this confirmation, Clarity activates its features—such as session recordings, heatmaps, and page view tracking—only for users who have consented. If the user declines, Clarity does not collect any data or set tracking cookies.

5. Consent changes are handled

If a user withdraws consent, call ConsentV2 again with "denied". Clarity will delete existing cookies, end the session, and restart in no-consent mode (temporary ID per page view, no cookies). This state remains until the user provides new consent, ensuring compliance and preventing data carryover.

Simplify Cookie Compliance with CookieYes

Manage user consent, stay compliant globally, and build user trust — without lifting a finger.

Get started for free

14-day free trialCancel anytime

Common use cases of Clarity Consent API across industries

Across industries, the Consent API ensures ethical analytics. Here are a few real-world examples:

  • E-commerce: A fashion brand uses Clarity to see where shoppers abandon their carts. Tracking only starts once a user agrees to analytics cookies. This protects personal data while uncovering UX issues.
  • Publishing: A news site uses Clarity to analyse scroll depth and reader engagement. The CMP ensures no data is collected without opt-in.
  • SaaS: A software platform analyses which features are most used during onboarding. But data is only collected after users give permission, helping to refine product design while remaining compliant.
  • Healthcare: A health portal uses session recordings to improve navigation for patients, but only after explicit consent, ensuring sensitive browsing data is treated with the required legal care.

Microsoft Clarity vs Google Analytics: Consent comparison

FeatureMicrosoft ClarityGoogle Analytics (GA4)
Default tracking behaviourStarts immediatelyRequires consent config
Consent API supportYes (manual integration)Yes (via Consent Mode)
Consent enforcement in EEA/UKMandatoryMandatory
Real-time user maskingYesLimited
Session continuity without cookiesNot supportedPartially supported
Heatmaps and session recordingsBuilt-inNot available

Avoiding common pitfalls in Clarity Consent API

Even when using the Consent API, missteps are common. Here’s how to avoid them:

  • Not disabling cookies by default: Some websites load Clarity with cookies active, even if the API is integrated. You must configure Clarity to remain idle until it receives consent.
  • Unclear consent categories: If your cookie banner doesn’t separate ‘necessary’ and ‘analytics’ cookies, users can’t make informed decisions.
  • Lack of consent logs: For full compliance, keep a record of when and how consent was obtained—this helps if you’re ever audited.
  • Ignoring consent withdrawal: Many implementations ignore what happens after a user revokes consent. This is risky. Once consent is withdrawn, tracking must stop, and associated cookies should be removed or disabled.
  • Incomplete regional targeting: Don’t limit consent enforcement to the EU alone. Extending compliant behaviour globally fosters a consistent brand experience and prepares you for future regulations.

Avoid all these pitfalls by integrating Clairty using CookieYes. As the only CMP fully supported by Microsoft Clarity, setup takes just a few minutes. Once configured, CookieYes automatically handles consent categories, regional targeting, and consent logs, so you can focus on insights while staying compliant.

Microsoft Clarity Consent API setting in CookieYes
CookieYes dashboard – just toggle to enable Clarity Consent API

Watch the setup in action:

Ready to simplify your Clarity integration and stay compliant?

Pro tips for advanced consent handling

  • Let users revoke consent easily: Add a “Cookie settings” link in your footer or privacy policy.
  • Use geo-targeting: Show cookie banners only in regions where consent is required.
  • Optimise performance: Load Clarity after other scripts to keep your site fast.

The future of privacy-first analytics

Using analytics tools shouldn’t be a trade-off between insights and ethics. With the Consent API, Clarity lets you:

  • Run behavioural analysis without breaching privacy laws.
  • Honour local regulations in regions like the EU, UK, and Switzerland.
  • Build transparency into your digital experience by default.
  • Increase the quality of analytics data by ensuring it is lawfully collected.

Future-facing brands know that compliance is not a barrier—it’s a brand value. As frameworks like the Digital Markets Act, ePrivacy Regulation, and US state-level laws evolve, tools like Clarity’s Consent API will become critical to your tech stack.

FAQs on Microsoft Clarity Consent API

Why do I need to use the Clarity Consent API?

If your website serves users in the European Economic Area (EEA), the United Kingdom, or Switzerland, you are required by law to obtain explicit user consent before placing cookies or tracking users with Microsoft Clarity. Starting in early 2025, Microsoft will enforce this requirement, and failure to implement the Consent API may result in loss of Clarity tracking capabilities.

How does the Clarity Consent API work?

The API works by allowing your consent management platform (CMP) or custom scripts to send the user’s consent decision to Clarity. For example, after a user accepts cookies, your script should call:

window.clarity("consentv2", { ad_Storage: "granted", analytics_Storage: "granted" });

If a user denies analytics or ad storage, you must pass "denied" for the relevant category. Clarity will then switch to no-consent mode and avoid setting cookies until proper consent is granted.

What happens if I don’t implement the Consent API?

Without proper implementation, Clarity cannot set cookies or track sessions for users who haven’t given explicit consent. Key analytics features like session recordings, funnels, and heatmaps will be disabled, especially for visitors in the EEA, UK, and Switzerland starting 31 October 2025.

Is the Clarity Consent API different from Microsoft UET Consent Mode?

Yes. The Clarity ConsentV2 API is specifically for Microsoft Clarity’s analytics tracking, while Microsoft UET Consent Mode applies to Microsoft’s advertising products.

Here are some more FAQs related to Clarity

Photo of Shreya

Shreya

Shreya is the Senior Content Writer at CookieYes, focused on creating engaging, audience-driven blog posts and related content. Off the clock, you’ll find her happily lost in the world of fiction.

Keep reading

Featured image of ChatGPT Cookies Explained: What They Are and Why They Matter

Cookies

ChatGPT Cookies Explained: What They Are and Why They Matter

As businesses increasingly rely on AI tools like ChatGPT, one question keeps coming up: How …

Read more
Featured image of Website Compliance: What Regulators Look for in Cookie Consent Reviews

ConsentCookies

Website Compliance: What Regulators Look for in Cookie Consent Reviews

Cookie compliance is one of the most visible and frequently assessed aspects of privacy compliance …

Read more
Featured image of Compliance Debt: What Happens When You Keep Postponing Cookie Consent Fixes?

Privacy Laws

Compliance Debt: What Happens When You Keep Postponing Cookie Consent Fixes?

Before diving into the mechanics of compliance debt, it helps to understand the landscape of …

Read more

Show all articles