Microsoft Clarity Cross-Domain Tracking
Overview
Cross-domain tracking lets you follow user journeys that span multiple domains or subdomains. For example, if your main site is on example.com but checkout happens on shop.example.com or checkout.thirdparty.com, cross-domain tracking ensures Clarity treats these as a single continuous session instead of two separate visits.
This guide explains how Clarity handles cross-domain scenarios, when you need special configuration, and how to implement it correctly.
How Clarity Handles Multiple Domains
Default Behavior: Automatic Subdomain Tracking
Clarity automatically tracks users across subdomains of the same root domain without any configuration.
Works automatically:
www.example.com→blog.example.com✅app.example.com→shop.example.com✅example.com→subdomain.example.com✅
Clarity uses first-party cookies on the root domain (.example.com), so sessions persist across all subdomains naturally.
No action required. Just install Clarity on all subdomains with the same Project ID.
When Cross-Domain Configuration Is Needed
Cross-domain tracking requires configuration when the user journey crosses different root domains:
Requires configuration:
example.com→examplestore.com❌example.com→checkout-provider.com❌example.com→partner-site.com❌
These scenarios require passing session identifiers between domains via URL parameters or postMessage APIs.
When to Use Cross-Domain Tracking
Common Scenarios
1. Separate Checkout Domains
- Main site:
example.com - Checkout:
secure-checkout.com(third-party payment processor)
2. Multi-Brand Properties
- Brand A:
brand-a.com - Brand B:
brand-b.com - User navigates between brands
3. Marketing Funnels Across Domains
- Landing page:
marketing-campaign.com - App signup:
app.mainproduct.com
4. Partnerships and Referrals
- Partner site:
partner.com - Your product:
yourproduct.com
When NOT to Use Cross-Domain Tracking
Subdomains of the same root domain:
- Already works automatically
- No configuration needed
Completely separate user journeys:
- If users on different domains are separate audiences with no overlap
- Tracking them together provides no value
Limitations of Cross-Domain Tracking in Clarity
Unlike Google Analytics, Microsoft Clarity does not have native cross-domain tracking features built into the platform.
What This Means
- No automatic cross-domain linker parameters
- No built-in configuration UI for cross-domain setup
- Session continuity across different root domains requires manual implementation
Workarounds
While Clarity doesn't support cross-domain tracking natively, you can maintain session continuity using:
- Shared User IDs: Identify the same user across domains
- Manual URL parameters: Pass session context between domains
- Separate projects with manual correlation: Track each domain separately and manually link sessions
Workaround 1: Shared User Identification
The most practical approach is to use clarity("identify") with the same user ID across both domains.
How It Works
- Generate a unique user identifier (e.g., from your authentication system or a first-party cookie)
- Pass this identifier to both domains
- Call
clarity("identify", userId)on both domains with the same ID - In Clarity, filter sessions by this user ID to see their cross-domain journey
Implementation
Domain A (example.com):
// Generate or retrieve a unique user ID
let userId = getCrossDomainUserId(); // Your function to generate/retrieve ID
// Identify the user in Clarity
clarity("identify", userId);
// When linking to Domain B, include userId in URL
function navigateToDomainB() {
window.location.href = `https://checkout.com/?userId=${userId}`;
}
Domain B (checkout.com):
// Extract userId from URL parameter
const urlParams = new URLSearchParams(window.location.search);
const userId = urlParams.get('userId');
if (userId) {
// Identify the user with the same ID
clarity("identify", userId);
}
getCrossDomainUserId() Example
function getCrossDomainUserId() {
// Check if userId exists in localStorage
let userId = localStorage.getItem('cross_domain_user_id');
if (!userId) {
// Generate new UUID
userId = 'user_' + Date.now() + '_' + Math.random().toString(36).substr(2, 9);
localStorage.setItem('cross_domain_user_id', userId);
}
return userId;
}
Filtering Sessions in Clarity
Once users are identified:
- Go to Clarity dashboard > Recordings
- Filter by User ID or create custom tags
- See all sessions for a specific user across both domains
Note: You'll see separate session recordings for each domain, but they'll be linked by the same user ID.
Workaround 2: Custom URL Parameters
Pass Clarity session metadata between domains via URL parameters.
How It Works
- On Domain A, capture key session context (user ID, campaign, source, etc.)
- Append this data as URL parameters when linking to Domain B
- On Domain B, extract parameters and set them as Clarity custom tags
- Filter sessions in Clarity by these tags to correlate cross-domain journeys
Implementation
Domain A (example.com):
// Tag session with context
clarity("set", "entry_domain", "example.com");
clarity("set", "user_journey", "checkout_flow");
// When navigating to Domain B, pass context
function goToCheckout() {
const context = {
journey: "checkout_flow",
referrer: "example_com",
sessionId: generateSessionId() // Your session ID
};
const params = new URLSearchParams(context).toString();
window.location.href = `https://checkout.com/?${params}`;
}
Domain B (checkout.com):
// Extract context from URL
const urlParams = new URLSearchParams(window.location.search);
const journey = urlParams.get('journey');
const referrer = urlParams.get('referrer');
const sessionId = urlParams.get('sessionId');
// Set Clarity tags to enable filtering
if (journey) clarity("set", "user_journey", journey);
if (referrer) clarity("set", "entry_domain", referrer);
if (sessionId) clarity("set", "linked_session_id", sessionId);
Analyzing Cross-Domain Journeys
- In Clarity, filter by custom tags like
user_journey: checkout_flow - See sessions from both domains that share the same journey context
- Manually review recordings to understand the full user experience
Workaround 3: Separate Projects with Manual Correlation
Use different Clarity projects for each domain and manually correlate sessions.
How It Works
- Create separate Clarity projects for each domain
- Install each project's tracking code on its respective domain
- Use shared identifiers (user ID, order ID, email hash) to manually link sessions
Implementation
Domain A (example.com) – Clarity Project A:
// Clarity Project A
(function(c,l,a,r,i,t,y){
// ... Clarity code ...
})(window, document, "clarity", "script", "PROJECT_A_ID");
// Tag with shared identifier
clarity("set", "order_id", "12345");
clarity("identify", "user_abc");
Domain B (checkout.com) – Clarity Project B:
// Clarity Project B
(function(c,l,a,r,i,t,y){
// ... Clarity code ...
})(window, document, "clarity", "script", "PROJECT_B_ID");
// Tag with the same identifier
clarity("set", "order_id", "12345");
clarity("identify", "user_abc");
Analysis Workflow
- In Project A, filter by
order_id: 12345oruser_id: user_abc - In Project B, filter by the same identifier
- Manually review sessions from both projects
- Piece together the full user journey
Pros:
- Clear separation of domains
- Independent analytics per property
Cons:
- No single unified view
- Manual work to correlate sessions
Best Practices
Use Hashed or Anonymized User IDs
Never pass PII (personally identifiable information) in URLs or Clarity identifiers.
❌ Don't:
clarity("identify", "user@email.com"); // PII!
✅ Do:
const hashedId = hashFunction("user@email.com");
clarity("identify", hashedId);
Consistent Naming Conventions
Use the same custom tag names across all domains:
// Domain A
clarity("set", "journey_stage", "awareness");
// Domain B
clarity("set", "journey_stage", "checkout"); // Same tag name, different value
This makes filtering and analysis consistent.
Document Your Cross-Domain Setup
Maintain documentation that includes:
- Which domains are linked
- What user ID or session ID scheme is used
- Which Clarity projects track which domains
- How to filter and correlate sessions
Example documentation:
| Domain | Clarity Project | User ID Scheme | Notes |
|---|---|---|---|
| example.com | Project A (abc123) | user_{timestamp}_{random} |
Main site |
| checkout.com | Project B (xyz789) | Same as Domain A | Checkout flow |
Test Cross-Domain Flows
- Navigate from Domain A to Domain B
- Check that user ID or session context is passed correctly
- Verify Clarity tags are set on Domain B
- Confirm you can filter sessions in Clarity dashboard
Alternative: Use Google Analytics for Cross-Domain
If you need robust cross-domain tracking, consider:
- Use Google Analytics 4 for cross-domain tracking (it has native support)
- Integrate Clarity with GA4 to get session recordings for cross-domain users
- Filter Clarity by GA dimensions (campaign, source, medium)
This way, GA4 handles cross-domain session continuity, and Clarity provides the behavioral insights for those sessions.
Setup Steps
- Configure GA4 cross-domain tracking (GA4 docs)
- Link Clarity with GA4 (Integration guide)
- In Clarity, filter recordings by GA4 dimensions to see cross-domain user journeys
Troubleshooting
User IDs Not Matching Across Domains
Symptoms: Different sessions on each domain despite passing user ID
Causes:
- User ID not extracted correctly from URL on Domain B
- localStorage blocked by browser privacy settings
- Typo in user ID parameter name
Fix:
- Log user ID in console to verify it's being passed and received
- Use URL parameters instead of localStorage for cross-domain data
- Ensure parameter names match exactly
Sessions Still Separate in Clarity
Expected behavior: Clarity treats each domain as a separate session
Workaround: Use filters and custom tags to manually group related sessions
Privacy Concerns with URL Parameters
Issue: Passing user IDs in URLs exposes them in browser history, referrer headers, logs
Fix:
- Hash or encrypt user IDs before passing
- Use server-side session matching instead of client-side URL params
- Consider using postMessage API for client-side cross-domain communication (advanced)
Summary
Microsoft Clarity does not have native cross-domain tracking like Google Analytics. However, you can maintain session continuity using:
- Shared user identification with
clarity("identify") - Custom URL parameters to pass session context
- Separate projects with manual correlation
For most use cases, shared user identification is the simplest and most effective approach. For more complex needs, integrate Clarity with Google Analytics 4 and leverage GA4's native cross-domain features.
Additional Resources:
- Event Tracking Setup – Learn how to use
clarity("identify")andclarity("set") - Google Analytics Integration – Combine Clarity with GA4 for enhanced tracking
- Clarity JavaScript API