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

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