Cross-Domain Tracking
Track visitors across multiple domains with seamless session stitching.
Cross-Domain Tracking
By default, EngageTrack treats each domain as a separate context. Cross-domain tracking lets you follow a single visitor across multiple domains (e.g., www.example.com to checkout.example.com) as one continuous session.
Cross-domain tracking requires storage mode (data-persistence="storage")
on both domains. In the default memory mode, there is no persistent visitor
ID to pass between domains. Storage mode requires a consent banner in the EU.
How It Works
- You list the destination domains in the
data-allowed-hostnamesattribute on the source domain - When a visitor clicks a link to an allowed hostname, the SDK appends
_et_vid(visitor ID) and_et_sid(session ID) as URL parameters - On the destination domain, the SDK reads those parameters, hydrates the visitor and session IDs into
localStorage/sessionStorage, and removes the parameters from the URL
The result is a seamless session that spans both domains.
Setup
Step 1: Configure the Source Domain
On every domain that links to another domain you own, add the destination hostnames to data-allowed-hostnames:
<!-- On www.example.com -->
<script
defer
data-site-id="YOUR_SITE_ID"
data-persistence="storage"
data-allowed-hostnames="checkout.example.com,app.example.com"
src="https://cdn.engagetrack.net/sdk.js"
></script>List only the exact hostnames (no protocol, no paths). Separate multiple
hostnames with commas. Both data-persistence="storage" and data-allowed-hostnames
are required on the source domain.
Step 2: Install the SDK on the Destination Domain
The destination domain must also have the EngageTrack script installed with the same site ID:
<!-- On checkout.example.com -->
<script
defer
data-site-id="YOUR_SITE_ID"
data-persistence="storage"
src="https://cdn.engagetrack.net/sdk.js"
></script>The SDK automatically detects _et_vid and _et_sid in the URL, hydrates the visitor identity into localStorage/sessionStorage, and cleans the URL.
Step 3: Use Regular Links
No special link markup is needed. The SDK intercepts clicks on outbound links and decorates them automatically:
<!-- This link will be decorated with _et_vid and _et_sid -->
<a href="https://checkout.example.com/buy">Complete Purchase</a>Cross-domain links opened via window.open() or programmatic navigation
are not automatically decorated. For those cases, build the URL manually
using window.engagetrack.getVisitorId() and
window.engagetrack.getSessionId().
Programmatic Navigation
If you navigate to a cross-domain URL with JavaScript:
const vid = window.engagetrack.getVisitorId();
const sid = window.engagetrack.getSessionId();
const url = new URL("https://checkout.example.com/buy");
url.searchParams.set("_et_vid", vid);
url.searchParams.set("_et_sid", sid);
window.location.href = url.toString();Bidirectional Tracking
If visitors can navigate in both directions (e.g., www to checkout and back), add data-allowed-hostnames on both domains:
<!-- On www.example.com -->
<script
defer
data-site-id="YOUR_SITE_ID"
data-persistence="storage"
data-allowed-hostnames="checkout.example.com"
src="https://cdn.engagetrack.net/sdk.js"
></script>
<!-- On checkout.example.com -->
<script
defer
data-site-id="YOUR_SITE_ID"
data-persistence="storage"
data-allowed-hostnames="www.example.com"
src="https://cdn.engagetrack.net/sdk.js"
></script>Verify It's Working
- Enable debug mode on both domains by adding
data-debug="true"to the script tag - Open the browser console on the source domain
- Click a link to the destination domain
- Look for
[EngageTrack] Cross-domain link decorated:in the console — this confirms the URL parameters were appended - On the destination domain, check for
[EngageTrack] Cross-domain: hydrated visitorandhydrated sessionmessages - Verify both domains report the same visitor ID by calling
window.engagetrack.getVisitorId()in the console on each domain