Microsoft Clarity Tag Setup Guide
This article describes how to set up the Microsoft Clarity tag in your Tealium iQ Tag Management account.
Microsoft Clarity is a free-to-use analytics product built to help website managers improve their website experiences by better understanding site visitor behavior.
Tag Tips
- Use mapping to dynamically override the project ID value
- For more information, see Bing: Microsoft Clarity is now Generally Available
Tag Configuration
Navigate to the Tag Marketplace to add a new tag. For more information, see About tags.
When adding the tag, configure the following settings:
- Project ID: The Clarity project ID. You can find your project ID from your Clarity project URL. For example,
https://clarity.microsoft.com/projects/view/PROJECT_ID/
. - Ad Storage Consent: Set the default consent for Ad Storage. Dynamically update this value by mapping the
ad_storage
parameter in the Data Mappings section. - Automatically read from Tealium Consent Cookie: If set to true, consent is set based on the Tealium Consent Manager.
Consent mode
There are two options to implement consent mode for this tag:
- Use Tealium Consent Management and automatically read the Tealium Consent cookie.
- Add a JavaScript Code extension to map consent choices and category mappings from your consent management platform (CMP) to this tag.
As visitors make their consent choices, the tag will choose the appropriate approach for first and third-party cookies:
- Granted: Both first-party and third-party cookies can be read and written.
- Denied: First-party cookies are neither read nor written, and third-party cookies are read-only for fraud and spam purposes, not for advertising.
Tealium Consent Management
To implement consent mode for this tag using Tealium Consent Management, set Automatically read from Tealium Consent Cookie to true
in the tag configuration.
JavaScript Code extension
To map end-user consent choices to Microsoft consent mode settings, use the JavaScript Code extension. Configure the extension as follows:
- Set Scope to After Load Rules (default)
- Set Occurrence to Run Always
- Enter the JavaScript code for your CMP. You can customize the following code template for your CMP by replacing
CUSTOM_LOGIC
with the logic for your vendor.
b.consent_decision = (tealiumConsentRegister && tealiumConsentRegister.currentDecision) || [];
b.microsoft_ad_storage_consent = CUSTOM_LOGIC ? 'granted' : 'denied';
For example, the following code is for OneTrust.
// After Load Rules - Run Always
b.consent_decision = (tealiumConsentRegister && tealiumConsentRegister.currentDecision) || [];
b.microsoft_ad_storage_consent = b.consent_decision.indexOf('C0004') !== -1 ? 'granted' : 'denied';
If you use these exact variable names, no additional mapping is required. The latest version of the tag uses these variables by default. Overwrite these variables by mapping the ad_storage
parameter to attributes for your specific case.
Load Rules
Load the tag on all pages or set conditions for when your tag will load. For more information, see About load rules.
Data Mappings
Mapping is the process of sending data from a data layer variable to the corresponding destination variable of the vendor tag. For more information, see About data mappings.
The available categories are:
Standard
Variable | Description |
---|---|
project_id |
The Clarity project ID. You can find your project ID from your Clarity project URL. For example, https://clarity.microsoft.com/projects/view/PROJECT_ID/ . |
Events
To map events, refer to Create an Event Mapping
Event | Description |
---|---|
enable_consent |
Enable consent |
disable_consent |
Disable consent |
This page was last updated: October 16, 2024