Skip to content

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

MetricDistortionBusiness impact
UsersInflated 40-60%Wrong audience size
SessionsDuplicated on each transitionSkewed engagement
SourcesOriginal lostMisallocated budget
ConversionsAttribution to directUndervalued campaigns
Bounce rateInflatedFalse 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 session

Components

Functions:

  • Track clicks on cross-domain links
  • Generate _gl parameter 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 _gl parameter
  • 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 typeExampleIncludes
Containsexample.comAll subdomains and paths
Exact matchshop.example.comOnly that domain
Starts withsecure.All domains with prefix
Ends with.example.comMain and subdomains
Regex^(shop|pay).exampleComplex 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:

  1. Open first domain in incognito
  2. Click link to second domain
  3. Check URL for _gl
  4. Open dev console
  5. Compare _ga cookie on both domains

Success signs:

  • _gl present
  • _ga matches 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

IssueCauseFix
_gl missingWrong domain configCheck exact domain match
Parameter dropped on transitionRedirects clear queryPreserve params in redirect rules
Different Client IDsCookie not overwrittenCheck allowLinker on receiving domain
Session resetsParameter expired (>2 min)Reduce redirects
Cookie blocking extensionsUser privacy settingsUse 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:#ffe6e6

Strategies:

  • 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:

ScenarioProblemFix
Redirect-based paymentMultiple redirectsWebhooks for server-side tracking
iFrame integrationIsolated contextPostMessage API
External checkoutFull context lossEnhanced e-commerce with transaction ID matching
Multi-step verificationParameter timeoutsSession 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 tracking

Benefits:

  • 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

MetricBeforeAfterChange
Users10,0006,500-35%
Sessions15,0008,000-47%
Bounce Rate65%45%-20pp
Conversion Rate1.2%2.1%+75%
Avg. Session Duration1:303:45+150%
Pages/Session2.35.7+148%

Historical data

When implementing:

  1. Annotate the implementation date in GA4
  2. Save baseline metrics
  3. Recalculate KPIs with new methodology
  4. Update dashboards with explanations
  5. 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.