Use this file to discover all available pages before exploring further.
Cross-domain tracking enables DATALYR to follow users as they navigate between different domains and subdomains, maintaining attribution and user identity throughout their journey.
DATALYR automatically reads the _dl_vid parameter from URLs on page load. However, you need to manually append the parameter to links when navigating to different domains.How it works:
You append _dl_vid to outbound links (manual step)
DATALYR automatically reads _dl_vid on the destination page (automatic)
The visitor ID is preserved across domains
Manual Linking (Required):
// Get visitor IDconst visitorId = datalyr.getAnonymousId();// Append to checkout URLconst checkoutUrl = `https://checkout.example.com?_dl_vid=${visitorId}`;// Redirectwindow.location.href = checkoutUrl;
On Destination Domain:
// DATALYR automatically reads _dl_vid from URL on page load// The visitor ID from the URL is used and stored in cookies/localStorage// Journey continues seamlessly with the same visitor ID
<!-- Install DATALYR - it automatically reads _dl_vid from URL on init --><script defer src="https://track.datalyr.com/dl.js" data-workspace-id="ws_123"></script><!-- The visitor ID from ?_dl_vid=anon_abc123 will be used automatically -->
Return Domain (yoursite.com/thank-you):
// Visitor ID persists via cookie on yoursite.com// Journey is complete and tracked
<form id="checkout-form" method="POST" action="https://checkout.example.com"> <input type="hidden" name="product_id" value="SKU123"> <!-- Visitor ID will be added by JavaScript --> <button type="submit">Checkout</button></form><script>document.getElementById('checkout-form').addEventListener('submit', function(e) { e.preventDefault(); const form = e.target; const visitorId = datalyr.getAnonymousId(); // Add visitor ID as hidden field const input = document.createElement('input'); input.type = 'hidden'; input.name = '_dl_vid'; input.value = visitorId; form.appendChild(input); // Submit form form.submit();});</script>
Checkout page reads visitor ID:
// checkout.example.com - DATALYR automatically reads _dl_vid from URL// Note: POST data reading requires server-side implementation// URL parameter method is recommended for client-side tracking
User navigates to www.example.comDATALYR reads cookie from .example.comSame visitor ID: anon_abc123Attribution preserved: facebook / cpc / IwAR123
Day 3: App (app.example.com)
User signs up on app.example.comDATALYR identifies user: - anonymous_id: anon_abc123 → user_id: user_456 - Attribution still preserved
Day 7: Checkout (checkout.stripe.com)
User clicks checkout buttonRedirected to: checkout.stripe.com?_dl_vid=anon_abc123Stripe processes paymentReturns to: www.example.com/thank-you?_dl_vid=anon_abc123
// User purchasesdatalyr.track('purchase', { order_id: 'ORDER_123', revenue: 99.99});// Automatically attributed to user_456// Includes original attribution from Domain 1
<!-- Install on every domain and subdomain --><script defer src="https://track.datalyr.com/dl.js" data-workspace-id="ws_123"></script>
Use Same Workspace ID
All domains/subdomains must use the same data-workspace-id.Call identify() After Login
Identify users immediately after login on any domain:
// After successful login on any domaindatalyr.identify(user.id, { email: user.email});
Preserve URL Parameters
Don’t strip UTM parameters or click IDs when redirecting between domains.Use HTTPS Everywhere
Secure cookies require HTTPS. Use HTTPS on all domains/subdomains.Test Cookie Persistence
// Check cookie on different subdomainsconsole.log('Visitor ID:', datalyr.getAnonymousId());console.log('Cookie:', document.cookie.match(/__dl_visitor_id=([^;]+)/));
Scenario: Checkout hosted on checkout.yoursite.com but different infrastructure.Solution:
// Main site (www.yoursite.com)<script defer src="https://track.datalyr.com/dl.js" data-workspace-id="ws_123"></script>// Checkout site (checkout.yoursite.com)<script defer src="https://track.datalyr.com/dl.js" data-workspace-id="ws_123"></script>// Cookie automatically shared via .yoursite.com
Scenario: Track users across multiple brand domains (brand1.com, brand2.com).Solution:
// Pass visitor ID via URL between brandsconst visitorId = datalyr.getAnonymousId();// Redirect to other brandwindow.location.href = `https://brand2.com?_dl_vid=${visitorId}`;// Track as same visitor across brands