Yes, the GDPR component integrates the Microsoft Clarity Consent Mode v2 required for Clarity tracking in the EEA, UK and Switzerland, especially after the enforcement date announced by Microsoft.
It’s possible to integrate the Microsoft Clarity Consent API for both analytics and advertising storage. Such consents can be granted or denied based on user preferences of the GDPR categories and transferred to the Clarity platform in real time.
IMPORTANT: If the GDPR tool is configured to block the domain
clarity.msor any script loading fromhttps://www.clarity.ms/tag/, remove it from all lists of blocked domains. Microsoft Clarity requires the script to load in order to apply the consent signals provided by the CMP.
In order to enable the integration with Microsoft Clarity Consent Mode, the GDPR component only requires that the Clarity tag is included in your website pages and that the following settings are enabled for the 'Statistics' and 'Marketing' categories. The GDPR component will automatically propagate any grant or denial for analytics and ads to Microsoft Clarity.
Below you can find the recommended snippet of code to integrate Microsoft Clarity correctly with deny-by-default consent mode. You must replace YOUR_CLARITY_ID with your real Microsoft Clarity project ID:
<script>
// 1. Send deny-by-default (safe & required by Clarity)
window.clarity = window.clarity || function(){(window.clarity.q = window.clarity.q || []).push(arguments)};
window.clarity("consentv2", {
analytics_Storage: "denied",
ad_Storage: "denied"
});
</script>
<!-- 2. Load Clarity after deny (CMP will unblock this script) -->
<script type="text/javascript">
(function(c,l,a,r,i,t,y){
c[a] = c[a] || function(){(c[a].q = c[a].q || []).push(arguments)};
t = l.createElement(r); t.async = 1; t.src = "https://www.clarity.ms/tag/" + i;
y = l.getElementsByTagName(r)[0]; y.parentNode.insertBefore(t,y);
})(window, document, "clarity", "script", "YOUR_CLARITY_ID");
</script>
This pattern ensures that Clarity receives a default “denied” state before loading the tag, and the GDPR CMP will later update the consent to “granted” or “denied” based on user preferences in the 'Statistics' and 'Marketing' categories.
If the user accepts the relevant categories, the GDPR component will automatically send:
window.clarity("consentv2", { analytics_Storage: "granted" }); window.clarity("consentv2", { ad_Storage: "granted" });
If the user declines them, the following will be sent:
window.clarity("consentv2", { analytics_Storage: "denied" }); window.clarity("consentv2", { ad_Storage: "denied" });
If the user chooses 'Reject All', the GDPR CMP will use:
window.clarity("consent", false);This command deletes Clarity cookies and forces Clarity into a strict no-consent mode until explicit consent is given again.
For more detailed information about the Microsoft Clarity v2 Consent API, refer to the official documentation:
https://learn.microsoft.com/en-us/clarity/setup-and-installation/clarity-consent-api-v2GDPR categories map to Microsoft Clarity consents in the following way:
- Statistics (category 3): analytics_Storage
- Marketing (category 4): ad_Storage
You can also test Microsoft Clarity consents directly from your browser console by inspecting theclarity.qqueue or by enabling the Clarity debug mode with:
window.clarity("set", "debug", true);