Clarity
Last updated May 10, 2026
Microsoft Clarity gives you session recordings, heatmaps, and behavioral insights. The clarity() helper sets up Clarity's queue stub, loads the vendor bundle, and keeps Clarity's consent state in sync as c15t measurement consent changes.
Integrate with c15t
How c15t loads it
- Category:
measurement(Analytics) - Loads when: measurement consent is granted
- On revocation: stays loaded (
persistAfterConsentRevoked: true) and receivesclarity('consent', false)so Clarity transitions into denied mode without tearing down the script.
Configure the integration
You can queue an initial Clarity consent value before the script loads.
Use an object when you need to map granular consent categories into Clarity's boot-time consent payload:
c15t queues that exact defaultConsent object during boot. Later consent changes are mapped to simple true or false values when c15t updates Clarity.
Tracking events in your app
c15t gates the Clarity script from loading until measurement consent is granted. Your application code that calls Clarity's runtime API (window.clarity(...)) is not automatically gated - window.clarity does not exist until the script is loaded, so unguarded calls before consent throw.
Guard event calls by checking consent state. From React:
From plain JavaScript: