Microsoft Clarity now supports Consent Mode v2, giving you more control over how session recording and analytics behave depending on user choices. This guide explains how to integrate Clarity with Cookie Control so that Clarity only activates once the user has granted the required consent. You'll learn how to set the default consent state to denied and update consent dynamically using onAccept and onRevoke callbacks.







<script type="text/javascript">
(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/XXXXXXX"; // your project ID
y = l.getElementsByTagName(r)[0];
y.parentNode.insertBefore(t, y);
})(window, document, "clarity", "script");
</script><script type="text/javascript">
(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/XXXXXXX"; // your project ID
y = l.getElementsByTagName(r)[0];
y.parentNode.insertBefore(t, y);
})(window, document, "clarity", "script");
window.clarity('consentv2', {
ad_Storage: "denied",
analytics_Storage: "denied"
});
</script>{
name: 'analytics',
label: 'Analytical Cookies',
description: 'Analytical cookies help us to improve our website by collecting and reporting information on its usage.',
onAccept: function () {
window.clarity('consentv2', { analytics_Storage: "granted" });
},
onRevoke: function () {
window.clarity('consentv2', { analytics_Storage: "denied" });
},
},
{
name: 'marketing',
label: 'Marketing Cookies',
description: 'We use marketing cookies to help us improve the relevancy of advertising campaigns you receive.',
onAccept: function () {
window.clarity('consentv2', { ad_Storage: "granted" });
},
onRevoke: function () {
window.clarity('consentv2', { ad_Storage: "denied" });
}
}