Cross-domain tracking
Cross-domain tracking follows users between different domains and merges fragmented sessions into one customer journey. Without it, each domain switch counts as a new visitor.
Data fragmentation
Cookies are bound to one domain. Other domains can't read them, by design. That breaks tracking on multi-domain setups.
Typical e-commerce flow
Store on example-store.com uses payments at payment-provider.com:
Without cross-domain tracking:
- User from ad campaign: session #1 on main site
- Payment redirect: session #2 on payment domain
- Result: 2 different users, lost conversion attribution
With cross-domain tracking:
- Single session across both domains
- Original source preserved
- Transaction credited to ad campaign
What breaks without it
| Metric | Distortion | Business impact |
|---|---|---|
| Users | Inflated 40-60% | Wrong audience size |
| Sessions | Duplicated on each transition | Skewed engagement |
| Sources | Original lost | Misallocated budget |
| Conversions | Attribution to direct | Undervalued campaigns |
| Bounce rate | Inflated | False quality signals |
How it works
Cross-domain tracking passes user identifiers via URL parameters between domains. Cookies keep the same IDs, transferred through a _gl URL parameter on links and forms.
sequenceDiagram
participant U as User
participant A as Domain A
participant B as Domain B
participant GA as Analytics
U->>A: Page visit
A->>GA: Create Client ID
A->>A: Store _ga cookie
U->>A: Click link to Domain B
A->>B: Pass ID via _gl parameter
B->>B: Extract Client ID
B->>GA: Continue same sessionComponents
Functions:
- Track clicks on cross-domain links
- Generate
_glparameter with encrypted Client ID - Auto-append to URL
- Handle forms and redirects
Notes:
- Linker parameters expire after two minutes, so they're added at click time
- Multi-domain support
- Works with dynamic links
Functions:
- Parse incoming
_glparameter - Validate timestamp
- Restore Client ID
- Overwrite local cookie
Notes:
- Auto-rejects expired parameters
- Verifies data integrity
- Preserves original source
GA4 setup
GA4 simplified cross-domain tracking compared to Universal Analytics. Setup is in the admin UI, no code or GTM required.
Step by step
Requirements
- Editor rights on GA4 property
- Same Measurement ID on all domains
- Code access on every tracked domain
- Maximum 100 domain conditions
Configuration:
Open Data Stream settings
- Admin → Data Streams
- Pick the web stream
- Click "Configure tag settings"
Add domains
- In Settings, click "Configure your domains"
- If the same Google tag is used across domains, they appear in Recommendations
- Add manually via "Add condition"
Match conditions
| Match type | Example | Includes |
|---|---|---|
| Contains | example.com | All subdomains and paths |
| Exact match | shop.example.com | Only that domain |
| Starts with | secure. | All domains with prefix |
| Ends with | .example.com | Main and subdomains |
| Regex | ^(shop|pay).example | Complex patterns |
Google Tag Manager
GTM gives more flexibility:
// Google Tag configuration with cross-domain
gtag('config', 'G-XXXXXXXXXX', {
'linker': {
'domains': ['example.com', 'checkout.example.com', 'payment-provider.com']
}
});
Why GTM
- Centralized management across domains
- Conditional firing
- Versioning
- Pre-publish testing
- Easy integration with other tags
Testing and debugging
Verifying setup is critical. Open a page with a link to the second domain, click it, and confirm the URL contains _gl, e.g. https://www.example.com/?_gl=1*abcde5*.
Verification
Steps:
- Open first domain in incognito
- Click link to second domain
- Check URL for
_gl - Open dev console
- Compare
_gacookie on both domains
Success signs:
_glpresent_gamatches on both- Session continues in GA4
Tools:
- GA4 DebugView for real-time
- Tag Assistant for tag validation
- Network tab for request analysis
- Cookie inspector for values
What to verify:
- Client ID consistency
- Session ID preserved
- Source attribution
- Event parameters
Common issues
| Issue | Cause | Fix |
|---|---|---|
_gl missing | Wrong domain config | Check exact domain match |
| Parameter dropped on transition | Redirects clear query | Preserve params in redirect rules |
| Different Client IDs | Cookie not overwritten | Check allowLinker on receiving domain |
| Session resets | Parameter expired (>2 min) | Reduce redirects |
| Cookie blocking extensions | User privacy settings | Use server-side tracking |
Special cases
Subdomains
GA4 tracks across subdomains by default. Caveats:
When subdomain setup is needed
- Different cookie domain settings
- Different GTM containers
- Custom JS implementation
- Need to filter specific subdomains
Multiple domains
For more than two domains:
graph TD
A[Main Site<br/>example.com] --> B[Blog<br/>blog.example.com]
A --> C[Store<br/>shop.example.net]
C --> D[Payments<br/>payment-gateway.com]
C --> E[Support<br/>support.example.io]
style A fill:#e8f4f8
style C fill:#fff4e6
style D fill:#ffe6e6Strategies:
- Minimize cross-domain transitions
- Keep critical processes on one domain
- Add fallback for parameter loss
- Monitor data integrity with custom alerts
Payment gateways
Payments add complexity:
| Scenario | Problem | Fix |
|---|---|---|
| Redirect-based payment | Multiple redirects | Webhooks for server-side tracking |
| iFrame integration | Isolated context | PostMessage API |
| External checkout | Full context loss | Enhanced e-commerce with transaction ID matching |
| Multi-step verification | Parameter timeouts | Session storage backup |
Alternatives
Server-side tracking
For business-critical flows:
sequenceDiagram
participant Browser
participant Server A
participant Server B
participant Analytics API
Browser->>Server A: Request with Client ID
Server A->>Server A: Store ID in session
Server A->>Analytics API: Send event
Browser->>Server B: Navigate to Domain B
Server A->>Server B: Pass ID via API
Server B->>Analytics API: Continue trackingBenefits:
- No browser limits
- Full data control
- Easy enrichment
- Ad-blocker resistant
First-party data
Build your own ID system:
Components
Identification:
- Persistent ID generation
- Cross-device matching
- Probabilistic fingerprinting
Storage:
- Centralized database
- Real-time sync
- State backup
Application:
- Push to analytics
- Enrich CRM
- Personalize experience
Impact on metrics
| Metric | Before | After | Change |
|---|---|---|---|
| Users | 10,000 | 6,500 | -35% |
| Sessions | 15,000 | 8,000 | -47% |
| Bounce Rate | 65% | 45% | -20pp |
| Conversion Rate | 1.2% | 2.1% | +75% |
| Avg. Session Duration | 1:30 | 3:45 | +150% |
| Pages/Session | 2.3 | 5.7 | +148% |
Historical data
When implementing:
- Annotate the implementation date in GA4
- Save baseline metrics
- Recalculate KPIs with new methodology
- Update dashboards with explanations
- Inform stakeholders about reporting impact
Best practices
Architecture
Optimal domain structure
Minimize domain count:
- Use subdomains over separate domains where possible
- Consolidate on main domain
- Avoid unnecessary redirects
Standard naming:
- Consistent subdomain prefixes
- Logical URL hierarchy
- Consistent parameters
Documentation
Maintain:
- All tracked domains
- Domain transition matrix
- Per-domain configuration
- Test procedures
- Owner contacts
- Change history
Monitoring
Regular checks:
graph LR
A[Daily] --> B[Check<br/>_gl parameter]
C[Weekly] --> D[Analyze<br/>self-referrals]
E[Monthly] --> F[Configuration<br/>audit]
G[Quarterly] --> H[Full<br/>testing]Future
Privacy-first
Privacy regulation forces new solutions:
- Privacy Sandbox APIs for aggregate reporting
- Consent-based tracking with granular permissions
- Federated Learning for analysis without data transfer
- Differential Privacy for individual data protection
Innovations
Emerging approaches
Edge Computing:
- Processing at CDN level
- Minimal latency
- Geographic distribution
Blockchain ID:
- Decentralized identification
- User-controlled data
- Transparent attribution
AI matching:
- Probabilistic user matching
- Behavioral pattern recognition
- Predictive journey completion
Statable approach
Statable removes the friction of traditional cross-domain tracking. Automatic detection of related domains and intelligent session linking, no complex setup or maintenance.
We are building tracking that survives cookie blocks and parameter loss. Multiple signals identify users.
The platform shows a visual map of cross-domain transitions with auto-detection of problem points. Find and fix tracking gaps without deep technical analysis.
No fixed domain limits. Each new domain joins the unified tracking system automatically.
About AI participation in writing articles
This article, like many others on our site, was created, written and proofread by a team of developers. Of course, not without the participation of AI assistants. We don't hide this and believe that modern systems are already quite good at handling simple tasks and, relatively speaking, writing an article about Viewport yourself is quite strange. It won't come out significantly better and will take a lot of time. But providing basic understanding to beginner webmasters is necessary. Of course, after the article is written by assistants - there's always proofreading, and this is where not one or two people participate, and only after that the article is published.
Ready to unify data across domains?
Sign up for a free trial of Statable. Get automatic cross-domain tracking, intelligent session linking, and a complete journey view.
Ready to take control of your web analytics? Try Statable free for 30 days — no credit card required, full feature access, GDPR-compliant by default. Start your free trial or view a live demo.