Overview
Microsoft Clarity setup is intentionally straightforward. Create a project, add a tracking script to your website, and start collecting behavioral data. Unlike complex analytics platforms that require weeks of configuration, Clarity can be up and running in under 15 minutes.
This guide walks through the complete implementation process, from initial setup to advanced configuration, ensuring you capture quality data while respecting user privacy.
Implementation Phases
Phase 1: Account Creation & Project Setup
Time required: 5 minutes
Create a Microsoft Account (if needed)
Clarity requires a Microsoft account (free):
- Go to https://clarity.microsoft.com/
- Click Sign up or Sign in
- Use an existing Microsoft account (Outlook, Office 365, Xbox, etc.) or create a new one
- Accept Clarity's terms of service
Create Your First Project
- After signing in, click Add new project
- Enter project details:
- Project name: Descriptive name (e.g., "Company Website Production")
- Website URL: Your site's primary domain (e.g.,
https://example.com) - Category: Select your industry (optional but helps with benchmarking)
- Click Add project
Clarity generates a unique Project ID and tracking code immediately.
Copy Tracking Code
- On the project setup screen, Clarity displays installation code
- Copy the entire script block (includes your unique Project ID)
- Keep this handy for the next phase
Tracking Code Example:
<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>
Phase 2: Installation & Tag Deployment
Time required: 5-10 minutes
Choose your installation method based on your tech stack:
- Manual HTML installation (any website)
- WordPress plugin (no-code option)
- Google Tag Manager (recommended for marketing teams)
- Shopify app
- Other CMS integrations
See the detailed Installation Guide for step-by-step instructions for each method.
Quick Start for Manual Installation:
- Open your website's main template/header file
- Locate the
<head>section - Paste Clarity tracking code just before the closing
</head>tag - Save and deploy
Example:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>My Website</title>
<!-- Other head elements -->
<!-- Microsoft Clarity -->
<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>
</head>
<body>
<!-- Page content -->
</body>
</html>
Phase 3: Verification & QA
Time required: 10-15 minutes
Before rolling out to production, verify Clarity is working correctly.
1. Check Script Installation
View Page Source:
- Visit your website
- Right-click > View Page Source (or Ctrl+U / Cmd+U)
- Search for "clarity.ms" (Ctrl+F / Cmd+F)
- Confirm the script appears in the
<head>section
Check Browser Console:
- Open DevTools (F12 or right-click > Inspect)
- Go to Console tab
- Look for Clarity-related messages (shouldn't see errors)
2. Verify Data Collection
Check Network Requests:
- Open DevTools > Network tab
- Reload your website
- Filter by "clarity"
- Look for:
- Request to
https://www.clarity.ms/tag/YOUR_PROJECT_ID(script load) - Requests to
https://www.clarity.ms/collect(data collection)
- Request to
Check Clarity Dashboard:
- Return to Clarity dashboard
- Go to Dashboard > Overview
- Within 5-15 minutes, you should see:
- Active sessions count increasing
- Recordings appearing in the Recordings section
Tip: Browse your site for 30+ seconds with several clicks and scrolls to generate a quality session for review.
3. Test Key Pages
Visit critical pages and verify tracking:
- Homepage
- Product/service pages
- Checkout or conversion pages
- Blog/content pages
- Mobile view (use DevTools device emulation)
Check for:
- No console errors
- Page performance not degraded
- Forms and interactions still work correctly
4. Review First Recordings
- In Clarity dashboard, go to Recordings
- Find your test session (filter by recent sessions)
- Watch the recording to ensure:
- Layout appears correctly
- Clicks are captured
- Scrolling is tracked
- No visual glitches or broken content
Phase 4: Privacy & Compliance Configuration
Time required: 10-20 minutes
Configure Clarity to comply with GDPR, CCPA, and your privacy requirements.
Enable Privacy Settings
- In Clarity dashboard, go to Settings > Privacy
- Configure masking options:
- Mask sensitive text: ON (recommended)
- Mask all input fields: ON for sensitive sites (finance, healthcare)
- Mask all images: ON if images may contain PII
Add Custom Masking
For specific elements that need masking:
<!-- Mask individual elements -->
<input type="text" name="ssn" class="clarity-mask">
<div class="clarity-mask">Sensitive user info here</div>
<!-- Mask entire sections -->
<section class="clarity-mask">
<h2>Private Member Dashboard</h2>
<p>User-specific content</p>
</section>
Implement Consent Management (If Required)
If your region requires user consent before tracking:
<!-- Only load Clarity after user consents -->
<script>
function loadClarity() {
(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");
}
// Call loadClarity() only after user consent
if (userHasConsented) {
loadClarity();
}
</script>
Integration with consent platforms:
- OneTrust
- Cookiebot
- Custom consent banners
See Integrations guide for specific consent platform examples.
Update Privacy Policy
Add language to your privacy policy:
"We use Microsoft Clarity to understand how you interact with our website. Clarity collects behavioral data such as mouse movements, clicks, and scrolling to help us improve user experience. Clarity automatically masks sensitive information like passwords and payment details. For more information, see Microsoft's privacy statement."
Phase 5: Advanced Configuration
Time required: Varies by complexity
Once basic tracking is working, enhance Clarity with advanced features.
Custom Event Tracking
Mark significant user actions for filtering and analysis:
// Example: Track feature usage
document.getElementById('dark-mode-toggle').addEventListener('click', function() {
clarity("event", "dark_mode_toggled");
});
// Example: Track checkout step completion
function onCheckoutStepComplete(step) {
clarity("set", "checkout_step", step);
clarity("event", "checkout_progress");
}
See Event Tracking Setup for detailed examples.
User Identification
Link sessions to known users (using hashed or anonymized IDs):
// After user login
function onUserLogin(userId) {
// Hash the user ID to protect privacy
const hashedId = hashFunction(userId);
clarity("identify", hashedId);
}
Privacy Warning: Never send PII (emails, names, phone numbers) to Clarity.
Google Analytics Integration
- In Clarity dashboard: Settings > Integrations > Google Analytics
- Sign in and authorize GA4 connection
- Select GA4 property to link
- Wait 24-48 hours for data to flow
See Integrations guide for detailed setup.
Cross-Domain Tracking
If your user journey spans multiple domains (e.g., main site → checkout subdomain):
See Cross-Domain Tracking for configuration details.
Phase 6: Production Rollout
Time required: Varies
Deploy Clarity to production with confidence.
Staged Rollout (Recommended)
- Dev/Staging Environment: Test Clarity with full QA process
- Canary Deployment: Enable for 10% of production traffic
- Monitor for 24-48 hours: Check for performance impact, errors, or data quality issues
- Full Rollout: Enable for 100% of users
Performance Monitoring
After deployment, monitor:
- Page load times: Use Google PageSpeed Insights or Lighthouse
- Error rates: Check browser console and error tracking tools
- User complaints: Monitor support channels for issues
Expected impact: Clarity adds 50-100ms to page load time. If you see > 500ms, investigate.
Data Quality Checks
After 48 hours of production data:
- Session count: Roughly aligns with your other analytics tools (allow 10-30% variance due to ad blockers)
- Recordings quality: Sample 20-30 recordings to ensure layout appears correctly
- Heatmaps: Check that heatmaps make sense (clicks on buttons, not random areas)
- Insights: Review automatic insights for false positives
Deployment Artifacts & Documentation
Maintain these artifacts for team reference and troubleshooting:
Tracking Plan
Document what Clarity tracks:
| Event/Tag | Trigger | Purpose | Owner |
|---|---|---|---|
checkout_complete |
Order confirmation page | Identify successful purchases | Marketing |
video_played |
Video play button click | Measure content engagement | Content Team |
user_type tag |
After login | Segment by user tier | Product |
Environment Matrix
Track where Clarity is deployed:
| Environment | Domain | Project ID | Deployed Date | Notes |
|---|---|---|---|---|
| Production | example.com | abc123 | 2024-01-15 | Full traffic |
| Staging | staging.example.com | xyz789 | 2024-01-10 | QA only |
| Development | localhost | def456 | 2024-01-08 | Dev team testing |
Access Control
Document who has access:
| User | Role | Permission Level | Date Added |
|---|---|---|---|
| jane@example.com | Admin | Full access | 2024-01-15 |
| john@example.com | Analyst | View only | 2024-01-20 |
| dev-team@example.com | Developer | View + Edit | 2024-01-15 |
Linked Runbooks
Detailed guides for specific implementation aspects:
- Install or Embed the Tag or SDK – Step-by-step installation for every platform
- Event Tracking Setup – Configure custom events and user identification
- Data Layer Setup – Structure data for advanced analysis
- Cross-Domain Tracking – Track users across multiple domains
- Server-Side vs Client-Side – Understand tracking architecture
Common Pitfalls & How to Avoid Them
1. Installing Tracking Code in the Wrong Place
Problem: Code placed in <body> or at the end of </html> doesn't load early enough.
Solution: Always place in <head> section before other scripts.
2. Not Testing Before Full Rollout
Problem: Broken recordings, performance issues, or privacy violations discovered after launch.
Solution: Test in staging, review recordings, check privacy masking before production.
3. Forgetting About Ad Blockers
Problem: Expecting 100% of users to be tracked, then seeing only 70-80%.
Solution: Understand that 10-30% of users block analytics. This is expected.
4. Sending PII Through Custom Events
Problem: Accidentally sending email addresses or names in event parameters.
Solution: Review all custom event implementations. Hash or anonymize any user identifiers.
5. Not Documenting Implementation
Problem: Six months later, no one remembers what events track or why.
Solution: Maintain a tracking plan and update it whenever changes are made.
Change Log & Ownership
Track changes for audit and troubleshooting:
| Date | Change | Who | Why |
|---|---|---|---|
| 2024-01-15 | Initial deployment to production | Jane Doe | Launch behavior analytics |
| 2024-01-20 | Added GA4 integration | John Smith | Combine quant + qual data |
| 2024-02-01 | Enabled strict masking mode | Jane Doe | GDPR compliance update |
| 2024-02-15 | Added checkout_complete event | Marketing Team | Track conversion flow |
Next Steps After Setup
Once Clarity is collecting data:
- Watch recordings daily (first week): Familiarize yourself with user behavior patterns
- Review automatic insights: Check for rage clicks, dead clicks, JS errors
- Create a heatmap review schedule: Weekly heatmap analysis for key pages
- Share with team: Invite stakeholders to Clarity project
- Integrate with workflow: Make Clarity a regular part of UX reviews, bug reports, and optimization meetings
Quick Reference:
- Troubleshooting guide – Fix common issues
- Event tracking guide – Learn what Clarity tracks automatically
- Integrations – Connect with other tools