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.
Since late 2024, Microsoft has required all Clarity users in these regions to enforce cookie consent. This means:
- You must collect user consent before Clarity can use cookies.
- Clarity won’t function fully unless the Consent API is implemented.
- You need to be ready to demonstrate compliance during audits.
This requirement aligns with key GDPR principles:
- Article 5(1)(a): Lawfulness, fairness, and transparency
- Article 6(1)(a): Consent as a lawful basis for processing data
- Article 7: Ability to demonstrate and manage consent
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.
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 later changes their mind and withdraws consent, your website can update Clarity using the same API to stop tracking immediately.
Simplify Cookie Compliance with CookieYes
Manage user consent, stay compliant globally, and build user trust — without lifting a finger.
Get started for free14-day free trialCancel anytime
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 before early 2025 to remain compliant and retain analytics functionality.
To enable tracking only after user consent, use the following call:
window.clarity('consent');
Example for practical use:
window.addEventListener("consentGranted", () => window.clarity('consent'));
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.
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
Feature | Microsoft Clarity | Google Analytics (GA4) |
---|---|---|
Default tracking behaviour | Starts immediately | Requires consent config |
Consent API support | Yes (manual integration) | Yes (via Consent Mode) |
Consent enforcement in EEA/UK | Mandatory | Mandatory |
Real-time user masking | Yes | Limited |
Session continuity without cookies | Not supported | Partially supported |
Heatmaps and session recordings | Built-in | Not 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. It’s easy and takes just a few minutes to configure. CookieYes automatically handles consent categories, regional targeting, and consent logs—so you can focus on insights while staying compliant.

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
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.
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 analytics cookies, your script should call window.clarity(“consent”) to activate Clarity tracking. If the user denies consent, Clarity tracking is not enabled
Without proper implementation, Clarity will not be able to set cookies or track sessions for users who have not provided explicit consent. This will impact key analytics features such as session recordings, funnel tracking, and page view connections.
Yes. The Clarity Consent API is specifically for managing consent for Microsoft Clarity’s analytics tracking, while Microsoft UET Consent Mode is a separate standard for Microsoft’s advertising products.
Here are some more FAQs related to Clarity