Tag Clarity Sessions by Feature Flag Instead of Watching Random Replays
Untagged Clarity replays drown in traffic. Tag sessions by feature flag at load time to filter recordings, heatmaps and rage clicks to the cohort you actually changed.
30 Dec 2025, 00:25 UTC

Shipping a checkout redesign behind a flag and seeing flat conversion is the classic qualitative gap. Quantitative dashboards tell you what changed, not why. Untagged Microsoft Clarity session recordings make that why hard to find because every session looks the same in a high-traffic app.
The useful takeaway: tag sessions at page load with the flag state and cohort, then filter Clarity recordings, heatmaps and rage clicks to that slice. You get targeted qualitative signal without custom instrumentation.
Why untagged replays do not scale
Clarity captures clicks, scrolls, rage clicks and dead clicks automatically and provides free session replays and heatmaps. That is powerful, but volume grows quickly. Manual review without filters is impractical.
Feature flags and experiment variants create the problem. Two users see different UIs, but Clarity records both under the same project. Without segmentation you compare apples to oranges and waste time watching irrelevant sessions.
How Clarity custom tags work
Clarity supports custom tags and user pseudonyms set via the snippet or data attributes. Tags are key-value metadata attached to a session. They appear as filters in the Clarity dashboard and let you isolate recordings by experiment variant, feature flag or backend cohort.
Tags are set client-side after the Clarity library loads. They are not secrets, so only use non-sensitive identifiers like flag names or cohort IDs. Do not put PII in tags.
Clarity also provides built-in data masking and automatic PII detection for form fields and element-level masking. Masking reduces compliance risk for GDPR and CCPA, but detection is heuristic and not guaranteed. Manual review of masking rules for sensitive inputs is required.
Worked example: tagging a checkout variant
The goal is to label sessions where the new checkout flow is enabled.
Set the tag after Clarity initializes, typically in the application bootstrap where the feature flag value is known. Run this in the browser context on the page, not server-side. Replace YOUR_PROJECT_ID with the ID from your Clarity project settings.
<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/"+i;
y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y);
})(window,document,"clarity","script","YOUR_PROJECT_ID");
</script>
<script>
// flagValue resolved by your feature flag provider
var flagValue = window.myFlags && window.myFlags.newCheckout ? "on" : "off";
clarity("set", "checkout_variant", flagValue);
// Optional pseudonym for cohort grouping, no PII
clarity("identify", "cohort_" + window.myCohort);
</script>Expected check: after a page load with the snippet, the tag appears in the Clarity dashboard under Filters and the session list can be narrowed to checkout_variant = on. Inspect form inputs in dev tools to verify masking attributes are applied, then replay a session to confirm sensitive fields appear blurred.
Risk: tags are visible in client source, so avoid secrets or personal data. Tags set after initial load may not retroactively apply to earlier events in the same session.
Trade-offs and limits
Session recording volume still grows with traffic. Tag-based segmentation helps, but retention and sampling limits mean Clarity is best used as a complementary qualitative layer, not a sole source of truth for metrics.
Automatic PII detection is heuristic, so manual review of masking rules for sensitive inputs is required for compliance. Custom events and page view tagging can correlate quantitative metrics with qualitative replays, but they add client-side code to maintain.
A practical way to validate signal is to create a controlled UI change and compare heatmap click density and rage click counts before and after deployment within the tagged segment only.
Ship the tag alongside the flag, define a short review checklist for the tagged segment, and remove or rename tags when the experiment ends to keep the dashboard clean.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.