Diagnosing Session Gaps and Data Loss in Microsoft Clarity
Learn how to diagnose and fix session recording gaps in Microsoft Clarity, from correcting CSP header blocks to optimizing script placement and masking attributes.
02 Jun 2026, 05:34 UTC

The Problem: Fragmented Recordings and Missing Data
When Microsoft Clarity recordings show gaps in user journeys, missing page views, or entirely empty sessions, the cause is rarely a platform outage. Instead, it is usually a failure in the telemetry pipeline—where the script is either blocked by the browser, prevented by security headers, or fails to execute before the user navigates away.
Diagnostic Matrix: Identifying the Root Cause
| Symptom | Likely Cause | Diagnostic Indicator |
|---|---|---|
| Initial page views missing from recordings | Incorrect script placement | Script located at the end of the body |
| No data appearing for specific users | CSP or Ad-blocker interference | Console errors mentioning clarity.ms |
| Recordings show blank screens or boxes | Over-aggressive masking | data-clarity-mask on parent containers |
| Single journey split into multiple sessions | Inactivity or session timeouts | Gaps in timestamps exceeding 30 minutes |
Step-by-Step Verification Process
Perform these checks in a staging environment or on a live page using Browser Developer Tools (F12). Use a private browsing window to ensure cached scripts aren't masking implementation errors.
1. Verify Script Execution and Placement
Clarity requires the tracking script to be in the <head> section. If placed in the <body> or at the bottom of the page, the user may navigate to a second page before the first page's telemetry is sent, resulting in a fragmented session.
- Check: Right-click the page > View Page Source.
- Requirement: The Clarity snippet must appear before the closing
</head>tag. - Risk: Moving scripts to the footer to "improve performance" often breaks the initial session capture.
2. Inspect Network Traffic for Blocked Requests
If the script is present but no data is flowing, the browser may be blocking the outbound request to the Clarity servers.
- Action: Open the Network tab in Developer Tools and filter by
clarity.ms. - Expected Result: You should see successful
POSTrequests to the telemetry endpoints. - Failure State: Requests marked as
(blocked:csp)or(blocked:devtools)indicate that a Content Security Policy or a browser extension is stopping the data.
3. Audit Content Security Policy (CSP) Headers
A strict CSP prevents the browser from loading scripts or sending data to domains not explicitly whitelisted. If your site uses CSP headers, Clarity will be silently blocked.
Required Configuration: Ensure your CSP includes the following directives to allow the Clarity script to execute and transmit data:
content-security-policy: script-src 'self' https://www.clarity.ms; connect-src 'self' https://*.clarity.ms;
Verification: Check the Console tab for warnings stating: Refused to load the script... because it violates the following Content Security Policy directive.
4. Evaluate Masking and Privacy Settings
If recordings exist but the content is unreadable, you may have implemented masking too broadly. Clarity uses data-clarity-mask to hide sensitive text and data-clarity-hide to remove elements entirely.
- The Error: Applying a masking attribute to a high-level container (like
<div id="main-content">) will mask every child element within that container. - The Fix: Apply masking only to the specific input fields or spans containing PII (Personally Identifiable Information).
Handling Consent Manager Gaps
If you use a GDPR or CCPA consent banner, the Clarity script is typically wrapped in a conditional trigger. This creates a natural data gap: users who decline cookies or ignore the banner will never be recorded. This is expected behavior, but if the gap is 100% of your traffic, verify that your consent manager's "Opt-in" event is actually triggering the script injection.
When to Escalate
If the following conditions are met, the issue is likely platform-side or related to a complex DOM conflict rather than implementation:
- Network tab shows
200 OKresponses forclarity.ms, but no recordings appear in the dashboard. - The script is correctly placed in the
<head>and CSP is configured. - The issue only occurs on pages with highly dynamic DOM updates (e.g., Single Page Applications that refresh content without changing the URL).
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.