How to implement Microsoft Clarity cookie consent with Shopify’s built-in cookie banner?

Hi everyone,

I’m using Microsoft Clarity on my Shopify store (www.kyotsu.ch). I received an email from Microsoft saying that starting October 31, 2025, Clarity will begin enforcing cookie consent requirements in the EEA, UK, and Switzerland.

Here’s the key part of their message:

Starting October 31st, you are required to share user consent signals for sessions originating from the EEA, UK, and Switzerland. If consent is not obtained and signaled using one of the supported methods (Google Consent Mode, supported CMPs, or Clarity Consent API), certain Clarity features such as session recordings and funnel tracking may be impacted.

Currently, I have Clarity installed by adding the following script in my theme.liquid file:

</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", "scovkpqv7i");
</script>
</head>

I’m using Shopify’s built-in cookie banner, not a third-party CMP.

My question is:
:backhand_index_pointing_right: Do I need to adjust this code so Clarity receives the correct consent signals?
If yes:

  • What would the updated code look like for Shopify with the native cookie banner?

  • Has anyone here already implemented this successfully, and can share an example or guidance?

I contacted Microsoft Clarity support, but I didn’t get a clear solution. They mentioned either using Google Consent Mode, a CMP like CookieYes, or the Clarity Consent API. I’d like to stay with Shopify’s built-in cookie banner if possible.

Any help, code examples, or guidance would be greatly appreciated! :folded_hands:

Thanks in advance,
Tobias

Hi Tobias,

The key point is that Shopify’s built-in cookie banner does not currently pass consent information to third-party scripts like Microsoft Clarity. So, if you keep the script as it is, Clarity may stop recording certain sessions in those regions after October 31, 2025.

There are a few approaches you can consider:

  1. Google Consent Mode
    If you already use Google Analytics or Ads, enabling Consent Mode can help because Clarity integrates with those consent signals.

  2. Third-party CMPs (CookieYes, OneTrust, etc.)
    These are purpose-built for GDPR compliance and automatically share consent signals with Clarity. The trade-off is that you’d replace Shopify’s native banner.

  3. Clarity Consent API (with Shopify’s Consent Tracking API)
    If you want to continue using Shopify’s native banner, you’ll need to connect it with Clarity manually. That means checking the user’s consent status before loading the Clarity script. For example:

    <script type="text/javascript">
      window.Shopify.loadFeatures(
        [{ name: 'consent-tracking-api', version: '0.1' }],
        function(error) {
          if (error) {
            console.error(error);
            return;
          }
          var userConsentGiven = Shopify.customerPrivacy.userCanBeTracked();
          if (userConsentGiven) {
            (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", "scovkpqv7i");
          }
        }
      );
    </script>
    
    

This way, Clarity only initializes if the visitor has given consent through Shopify’s banner.

Hopefully this gives you a clear path forward!

Let me know if you are able to get it done or you encounter any difficulty

Is this enough?

I see on Clarity Cookie Consent API - ConsentV2 | Microsoft Learn

the API:

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

with only cookieyes and webtoffee automatically integrated, as per:

list of CMPs

It says here that Shopify Cookie Banner sends signals to MS → Clarity Cookie Consent for Third-Party Platforms | Microsoft Learn