Articles on: Integrations

Integrating Microsoft Clarity Consent API Using Pandectes

Microsoft Clarity is a free analytics tool that offers heatmaps and session recordings to help you understand user behavior on your website. However, since Clarity collects behavioral data, using it in the EU requires prior user consent under the GDPR and ePrivacy Directive.


With Pandectes, you can easily integrate Microsoft Clarity into your Shopify store and ensure that data collection only starts after valid user consent is obtained.


Prerequisites


Before you start:


  • You must have a Microsoft Clarity account.
  • Your Shopify store should have the Pandectes GDPR Compliance app installed and configured.
  • Make sure you have enabled the Microsoft Clarity integration inside the app.



The Clarity Consent API lets you control what Clarity can track based on the user's consent choices. This helps you stay compliant with GDPR and prevents unauthorized data collection.
Clarity uses two independent consent types:


Clarity permission

What it covers

Pandectes cookie category

analytics_Storage

User behavior, sessions, heatmaps

Performance / Analytics

ad_Storage

Retargeting, conversions, ad performance

Marketing / Advertising


Each permission can be granted or denied independently. For example, a user can accept analytics but decline advertising. Pandectes respects and communicates each choice to Clarity separately.


How the Integration Works


When the integration is enabled, Pandectes sends consent signals to Clarity based on the user's choices. However, no cookies are set, and no tracking occurs until the appropriate consent signal is received.
to Clarity separately


How the Clarity script is loaded depends on whether you provide a Project ID in the Pandectes settings:

  • With a Project ID: Pandectes loads the Clarity script automatically as early as possible during page load, following Microsoft's official recommendation that the script runs regardless of consent status so signals are never missed.
  • Without a Project ID: You are responsible for loading the Clarity script on your store. Pandectes will still send the consent signals, but the script must be present on the page for them to take effect.


Here is what happens after the user interacts with the consent banner:


  1. Pandectes reads the user's cookie choices.
  2. For each accepted category, the corresponding Clarity permission is set to "granted".
  3. For each declined category, the corresponding permission is set to "denied".
  4. Pandectes calls the Clarity Consent API with the resolved permissions.



When consent is denied, Clarity does not simply stop, it switches to cookieless mode, which means:

  • No cross-session tracking takes place.
  • The cookies that require consent are not set (see table below).
  • Limited, non-identifying data may still be collected.



Cookie

Requires

_clck (first-party)

analytics_Storage=granted

_clsk (first-party)

analytics_Storage=granted

MUID

ad_Storage=granted



Before Pandectes can communicate consent to Clarity, you need to make sure Consent Mode is active in your Clarity project settings. This prevents Clarity from setting cookies before a valid consent signal is received.


Note: Consent Mode is enabled by default for visitors from the European Economic Area (EEA), United Kingdom, and Switzerland. If your store sells exclusively in these regions, no change is needed. For stores with a global audience, follow the steps below.



  • Go to your Microsoft Clarity dashboard.
  • Navigate to Settings → Setup.
  • Scroll down and turn off the Cookies option.
  • Clarity will confirm that cookies are disabled until consent is received.



After setting up the integration, you can verify that Clarity is correctly receiving consent signals from Pandectes:


  1. Open your store in a browser and open Developer Tools (Ctrl+Shift+I / Cmd+Option+I).
  2. Go to the Console tab.
  3. Paste and run the following:
clarity('metadata', (d, upgrade, consent) => {
console.log('consentStatus:', consent);
}, false, true, true);
  1. If consent has not been granted, you should see:
{ "analytics_storage": "DENIED", "ad_storage": "DENIED" }
  1. After accepting cookies in the Pandectes banner, the output should update to reflect the user's choices.


Enable Microsoft Clarity in Pandectes

Follow these steps:


  1. Log in to your Shopify store and access the Pandectes app.
  2. Go to Settings > Integrations.
  3. Scroll to Microsoft Clarity and click Configure.

  1. Toggle the switch to enable the integration.
  2. (Optional) Paste your Clarity Project ID if you want Pandectes to load the Clarity script for you. If left blank, you must load the script on your store independently.



Once enabled, Pandectes will:

  • Send granular consent signals (analytics_Storage and ad_Storage) based on the user's actual choices.
  • Prevent any Clarity cookies from being written until the corresponding consent is granted.
  • Load the Clarity script automatically (only when a Project ID is provided), as early as possible during page load so consent signals are never missed.


Final Notes


This integration is fully compliant and optimized for:

  • Shopify stores selling in the EU
  • Merchants under GDPR, CCPA, and other privacy frameworks
  • Stores seeking automated, granular control over third-party tracking


For more details, see Microsoft's official documentation on CMP integration with Clarity.

Updated on: 15/06/2026

Was this article helpful?

Share your feedback

Cancel

Thank you!