Overview
Cross-domain tracking in Matomo ensures visitor sessions persist when users navigate between different domains you own. Without proper configuration, each domain transition creates a new visitor session, fragmenting your analytics data and making conversion attribution impossible.
When Cross-Domain Tracking Is Required
- Multi-domain journeys: Main site to checkout subdomain (e.g.,
www.example.comtocheckout.example.com) - Third-party payment providers: Redirects to payment gateways that return users to your confirmation page
- Microsites and campaign landing pages: Promotional sites that funnel users to the main conversion domain
- International domains: Country-specific TLDs that share a common user journey (e.g.,
.com,.co.uk,.de) - App-to-web transitions: Mobile app deep links that open web content in a browser
Configuration Steps
Using setDomains
Add all domains that should share visitor sessions to the setDomains configuration:
_paq.push(['setDomains', [
'*.example.com',
'*.checkout.example.com',
'payments.thirdparty.com'
]]);
The asterisk wildcard includes all subdomains. List the primary domain first as it becomes the cookie domain.
Enabling the Cross-Domain Linker
For Matomo Tag Manager deployments:
- Navigate to Variables and create a constant variable containing your domain list
- In your Matomo Configuration tag, enable Enable cross domain linking
- Add all domains to the Domains field, comma-separated
- The linker automatically appends
pk_vidparameters to cross-domain links
For direct JavaScript implementation:
_paq.push(['enableCrossDomainLinking']);
_paq.push(['setDomains', ['*.example.com', '*.partner-site.com']]);
Referral Exclusions
Prevent sibling domains from appearing as traffic sources:
- In Matomo, go to Administration > Websites > Manage
- Select your site and navigate to Excluded Parameters
- Add all domains participating in cross-domain tracking to Excluded Referrers
This ensures users returning from checkout or payment domains retain their original attribution.
Third-Party Checkout Handling
When users redirect to external payment providers (Stripe, PayPal, Adyen):
- Pre-redirect capture: Store the Matomo
visitorIdin a server-side session or pass it as a URL parameter to the payment provider - Return URL configuration: Include the
pk_vidparameter in the return/callback URL from the payment provider - Post-redirect restoration: Matomo automatically reads the
pk_vidparameter and restores the visitor session
Example return URL structure:
https://example.com/order-confirmation?pk_vid=abc123xyz789&order_id=12345
Edge Cases and Considerations
Cookie Consent Impact
Cross-domain linking requires cookies to be accepted. For cookieless tracking:
- The linker still works but relies entirely on URL parameters
- Session continuity may be less reliable without persistent cookies
- Consider first-party data strategies for high-value conversions
Link Decoration Blockers
Some browsers and privacy extensions strip URL parameters:
- Implement server-side session stitching as a fallback
- Use first-party subdomains where possible to reduce parameter reliance
- Monitor cross-domain conversion rates for anomalies indicating blocking
iFrame Embeds
When embedding content via iframes across domains:
- Parent and child frames must both have Matomo tracking
- Use
postMessageto pass visitor identifiers between frames - Consider whether the embedded content genuinely needs tracking
Validation Steps
Pre-Launch Testing
- Tag Manager Preview: Enable Matomo Tag Manager preview mode and navigate through cross-domain flows
- Network inspection: Verify
pk_vidparameters appear on cross-domain links in browser DevTools - Real-Time dashboard: Confirm a single visitor session spans multiple domains
- Cookie inspection: Check that the
_pk_idcookie domain matches your configuration
Post-Launch Monitoring
- Compare pre- and post-implementation session counts per domain
- Review conversion attribution reports for accuracy
- Check that referral traffic from internal domains has dropped to near zero
- Validate ecommerce funnel completion rates across domain transitions
Troubleshooting Common Issues
| Symptom | Likely Cause | Solution |
|---|---|---|
| Sessions split at domain boundary | setDomains missing target domain |
Add all domains to configuration |
| Internal domains appear as referrals | Referral exclusions not configured | Add domains to exclusion list |
pk_vid not appearing on links |
Cross-domain linking not enabled | Enable linker in Tag Manager or JS |
| Session lost after payment redirect | Return URL missing pk_vid |
Configure payment provider callbacks |