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.
What is the Clarity Consent API?
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 |
|---|---|---|
| User behavior, sessions, heatmaps | Performance / Analytics |
| 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:
- Pandectes reads the user's cookie choices.
- For each accepted category, the corresponding Clarity permission is set to
"granted". - For each declined category, the corresponding permission is set to
"denied". - Pandectes calls the Clarity Consent API with the resolved permissions.
What Clarity does without consent
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.
Cookies controlled by consent
Cookie | Requires |
|---|---|
|
|
|
|
|
|
Enabling Consent Mode in Clarity
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.
Enable Consent Mode in Clarity Settings
- 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.

Verify consent is working correctly
After setting up the integration, you can verify that Clarity is correctly receiving consent signals from Pandectes:
- Open your store in a browser and open Developer Tools (
Ctrl+Shift+I/Cmd+Option+I). - Go to the Console tab.
- Paste and run the following:
clarity('metadata', (d, upgrade, consent) => {
console.log('consentStatus:', consent);
}, false, true, true);
- If consent has not been granted, you should see:
{ "analytics_storage": "DENIED", "ad_storage": "DENIED" }- 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:
- Log in to your Shopify store and access the Pandectes app.
- Go to Settings > Integrations.
- Scroll to Microsoft Clarity and click Configure.

- Toggle the switch to enable the integration.
- (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_Storageandad_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
Thank you!
