Microsoft Clarity and cookie consent

Have more questions? Submit a request

Users from the EEA, UK and Switzerland are now required to give consent before you can track them with Microsoft Clarity consent. 

Step 1: Disable Microsoft Clarity cookies

First we need to make sure that your Clarity setup has the setting of cookies disabled by default. Yo can do this by going to Clarity > Settings > Setup. Turn off the cookies, see the screenshot.

cookie-settings-microsoft-clarity.png

Step 2: Add helper scrip to the banner or your website

To make sure that Clarity will start tracking users after they give consent we need to make sure that the cookie banner updates the consent for Microsoft Clarity. 

There are two ways we can do this. 

1. Add script a Script to the cookie banner

By adding a small script to the cookie banner under the performance category we can make sure that clarity will receive the correct signals for tracking the users.

Here is the code snippet:

  <script> window.clarity('consent'); </script>

 

2. Add helper script to website

Here is another way to do it if you have access to the website code and want to integrate it there you can use the following code snippet to connect the cookie banner to microsoft clarity consent. 

<!-- Cookiefirst Microsoft clarity helper -->
  <script>
function handleConsentChange(e) {
    var consent = e.detail || {};
    var performanceConsent = consent.performance || null; // Get advertising consent from event detail

    if (performanceConsent === true) {
        // Enable Clarity tracking
        window.clarity('consent');
    } else if (performanceConsent === false || performanceConsent === null) {
        // Disable Clarity tracking
        window.clarity('consent', false);
        
} else { console.error("Unexpected performance consent value:", performanceConsent); } } // Add event listeners for cf_consent and cf_consent_loaded window.addEventListener("cf_consent", handleConsentChange); window.addEventListener("cf_consent_loaded", handleConsentChange); </script>

 

Microsoft Clarity Cookie Consent: Ensuring Compliance in the UK, EEA, and Switzerland

Microsoft Clarity is a powerful analytics tool that helps website owners track user behavior, understand session data, and enhance user experience. A crucial aspect of Clarity's functionality relies on cookies to link page views and sessions, enabling features like session recordings and funnel tracking. However, in regions like the UK, EEA, and Switzerland, websites must comply with local data privacy laws, such as the GDPR and the ePrivacy Directive. These regulations require explicit user consent before cookies are placed on their devices, making cookie consent management essential for Clarity users in these areas.

To stay compliant, website publishers must implement Clarity’s Consent API, which facilitates collecting and managing user consent effectively. Without explicit consent, critical features of Clarity may be unavailable, impacting your analytics capabilities. By proactively updating your Clarity setup and ensuring proper consent mechanisms, you can continue leveraging its powerful insights while adhering to regulatory requirements in these regions. Read more in the article on our website.

Articles in this section

Was this article helpful?
2 out of 5 found this helpful
Share