> ## Knowledge Base Index
> Fetch the complete knowledge base index at: https://help.pandectes.io/sitemap.xml
> Use this file to discover available pages before exploring further.
> Pure-Markdown content can be obtained by appending a '.md' suffix to the content URLs listed in the sitemap (without the trailing slash).

# 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](https://apps.shopify.com/gdpr-cookie-consent) 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 |
| ---- |
| `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](https://learn.microsoft.com/en-us/clarity/setup-and-installation/cmp-integration-guide) 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.

###### 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 |
| ---- |
| `_clck` (first-party) | `analytics_Storage=granted` |
| `_clsk` (first-party) | `analytics_Storage=granted` |
| `MUID` | `ad_Storage=granted` |

### 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.

|| 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.

###### Enable Consent Mode in Clarity Settings

* Go to your [Microsoft Clarity dashboard](https://clarity.microsoft.com/).
* Navigate to **Settings → Setup**.
* Scroll down and turn **off** the **Cookies** option.
* Clarity will confirm that cookies are disabled until consent is received.

![](https://storage.crisp.chat/users/helpdesk/website/-/1/a/5/a/1a5af239e847cf00/image_ho0429.png =800x405)
###### Verify consent is working correctly

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);
```
4. If consent has not been granted, you should see:
```
{ "analytics_storage": "DENIED", "ad_storage": "DENIED" }
```
5. 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 **Integrations**.
3. Scroll to **Microsoft Clarity** and click **Configure**.
![](https://storage.crisp.chat/users/helpdesk/website/-/1/a/5/a/1a5af239e847cf00/image_eszb4s.png =300x225)
1. Toggle the switch to **enable the integration**.*&#32;*
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.

![](https://storage.crisp.chat/users/helpdesk/website/-/1/a/5/a/1a5af239e847cf00/image_tiaixj.png =800x315)

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](https://learn.microsoft.com/en-us/clarity/setup-and-installation/cmp-integration-guide).