TrueTrackedTrueTracked

Cross-Domain Tracking

If your visitor journey spans more than one domain (e.g. a marketing site that hands off to a separate checkout subdomain, or to a third-party booking provider), you need to carry the TrueTracked visitor identifiers across the boundary. Otherwise the visitor looks like two separate people: one on each domain.

TrueTracked solves this with link decoration: append ?tt_user_id=...&tt_session_id=... to any outbound link, and the destination's SDK reads those parameters on landing and continues the same session.

When you need this: Marketing site that hands off to a separate checkout subdomain (e.g. www.example.com to checkout.example.com), funnel jumps between two of your own root domains, payment-link checkouts hosted on a third-party provider's domain, or any other multi-domain visitor journey.

Prerequisites

The TrueTracked base pixel must be installed on BOTH the source domain (where you decorate the outbound link) and the destination domain (where you read the identifiers on landing). See Pixel Installation.

How it works

  1. Visitor lands on your source domain (e.g. www.example.com); SDK assigns them a tt_user_id + tt_session_id
  2. Just before they click an outbound link (a "Continue" button, "Checkout" link, etc.), a GTM tag rewrites the anchor's href using window.truetracked.getDecoratedUrl()
  3. The decorated URL carries the identifiers as query params:
    https://checkout.example.com/?tt_user_id=...&tt_session_id=...
  4. On the destination domain, the SDK reads those params on landing (via its built-in getCrossDomainIdentifiers() hook) and adopts the same tt_user_id / tt_session_id. Same visitor; continuous journey.

GTM setup: decorate outbound anchors

Create a Custom HTML tag in your GTM container on the source domain. The tag finds outbound links matching a CSS selector and rewrites their href when clicked. Adjust the selector to match the buttons or links that lead to your other domain.

<script>
(function() {
  // CSS selector for outbound anchors that need cross-domain decoration.
  // Adjust to match your own outbound links (by host, class, or data attribute).
  var SELECTOR = 'a[href*="checkout.example.com"], a.cross-domain-link';

  function decorate(anchor) {
    try {
      if (!anchor.href || anchor.dataset.ttDecorated === '1') return;
      if (!window.truetracked || !window.truetracked.getDecoratedUrl) return;
      anchor.href = window.truetracked.getDecoratedUrl(anchor.href);
      anchor.dataset.ttDecorated = '1';
    } catch (e) {}
  }

  function scan() {
    document.querySelectorAll(SELECTOR).forEach(decorate);
  }

  // Decorate now and on any DOM mutation (handles dynamically-added links).
  if (document.readyState === 'loading') {
    document.addEventListener('DOMContentLoaded', scan);
  } else {
    scan();
  }
  new MutationObserver(scan).observe(document.body, { childList: true, subtree: true });

  // Also decorate at click-time as a safety net for late-attached anchors.
  document.addEventListener('click', function(e) {
    var a = e.target.closest && e.target.closest('a');
    if (a) decorate(a);
  }, true);
})();
</script>

Set the trigger to All Pages. The script runs once, decorates matching anchors, and re-runs whenever the DOM changes.

Destination domain: no setup needed

On the destination domain, the TrueTracked SDK automatically reads the tt_user_id and tt_session_id query params on landing and adopts them. No manual call required. Just make sure the base pixel is installed.

Manually decorate a URL in code

If you generate links server-side or via a framework (rather than rewriting hardcoded HTML anchors), call the decorator directly:

var targetUrl = 'https://checkout.example.com/?lang=en';
var decorated = window.truetracked.getDecoratedUrl(targetUrl);
// decorated now contains: https://checkout.example.com/?lang=en&tt_user_id=...&tt_session_id=...
window.location.href = decorated;

Verifying it works

  1. Open your marketing site in a browser with DevTools open
  2. Inspect the outbound anchor element after page load - the href should include tt_user_id and tt_session_id params
  3. Click the link and land on the destination domain
  4. In DevTools console run window.truetracked.getUserId() - it should return the same tt_user_id the source domain had
  5. In the TrueTracked dashboard journey view, the visitor should appear as a single continuous session across both domains

Troubleshooting

  • Anchors not getting decorated: Check your CSS selector matches the actual anchor element. Use DevTools to inspect the anchor and confirm data-tt-decorated="1" appears after page load.
  • Anchor decorated, but destination doesn't pick up the params: Confirm the base pixel is installed on the destination domain (View Page Source on the destination, search for t.ttrkd.com/tt.js). The SDK adopts cross-domain params automatically on landing. If the destination is a third-party domain you don't control, this approach won't work - that's a server-side webhook case instead.
  • Identifiers expire too fast: The decorated params have no expiry on their own, but the visitor's cookie on the destination domain is subject to standard browser cookie lifetimes. For longer first-party cookie life, set up a custom tracking domain on both sides.
  • Outbound link uses window.open or location.href in JS, not an anchor: Decorate the URL programmatically before the navigation:
    window.open(window.truetracked.getDecoratedUrl(url));