TrustData
Tracking

First-party tracking domain

Serve the TrustData tracking script and event endpoint from your own domain with a CNAME record or a reverse proxy.

By default the SDK loads from https://t.trustdata.tech and sends events there. A first-party tracking domain moves both to a hostname you own, such as t.yourdomain.com or yourdomain.com/_td. Requests then count as first-party, and the visitor cookie TrustData sets lives on your domain.

TrustData offers two delivery modes. Pick one in the Delivery mode field.

ModeWhat you set upSafari cookie life
CNAMEOne DNS record that points a subdomain at t.trustdata.techSafari caps the server cookie to 7 days
Reverse proxy (first-party, ITP-durable)A rule on your own web server or CDN that forwards /_td/* to TrustDataThe cookie survives Safari

Choose the reverse proxy when you can run one. Choose CNAME when you can only change DNS.

Open the setting

  1. Go to Settings → Attribution IDs.
  2. Select the attribution ID of the stream.
  3. Open the Delivery tab.
  4. Find the Tracking domain section.

You need the admin or edit role to change it. Select Save delivery after each change.

Set up a CNAME domain

  1. Set Delivery mode to CNAME.
  2. In Custom domain, enter a subdomain such as t.yourdomain.com. TrustData rejects subdomains of trustdata.tech, trustdata.io and trustdata.com.
  3. Select Save delivery. The Verify the domain section appears with a CNAME record.
  4. At your DNS provider, create that record. It points your subdomain at t.trustdata.tech. The page also tells you to turn on the Cloudflare proxy (orange cloud) for automatic SSL.
  5. Select Verify DNS. When the record resolves, the field shows a Verified badge.

Until the domain is verified, the field shows Pending and events keep going to the default endpoint.

Set up a reverse proxy

  1. Set Delivery mode to Reverse proxy (first-party, ITP-durable).
  2. In Custom domain, enter the hostname visitors see, such as yourdomain.com. The apex and www spellings both work, whichever you enter.
  3. Select Save delivery. The Verify the domain section appears with a TXT record.
  4. At your DNS provider, create that record. The name is _trustdata-verify.yourdomain.com and the value is the token shown on the page. You do not need a CNAME record in this mode.
  5. Select Verify DNS.
  6. Add the proxy rule to your web server or CDN. See What the proxy must do.
  7. Select Test proxy.

If you change the domain or the delivery mode, TrustData verifies again. It issues a new TXT token, and the record you published before no longer verifies.

What the proxy must do

The collector reads these parts of each request. A proxy that satisfies all of them gives full cookie durability.

  • Path. Forward everything under /_td/ and remove the /_td prefix. The collector serves /t.js, /api/events, /api/config/... and /m/..., and does not know /_td. For example, /_td/api/events must arrive as /api/events.
  • X-Forwarded-Host. Set it to your domain. The collector matches your attribution ID to your verified domain with this header. Without it, the collector falls back to the Host header, finds no domain, and sets no durable cookie. If the header holds a comma-separated list, the collector reads the first entry.
  • X-Forwarded-For. Put the visitor's IP address first. For a verified reverse proxy domain, the collector reads the first entry that is a valid IP address. Without it, every visitor appears at the address of your proxy.
  • X-Forwarded-Proto. Send https. The collector writes the script's own origin from it.
  • Cookie and Set-Cookie. Pass the request Cookie header and the response Set-Cookie header through unchanged. The collector sets the _trdt_vid_s cookie as HttpOnly with Path=/_td, and only when the visitor has granted analytics consent.
  • Prefix other than /_td. If you mount the proxy on another path, send it in X-Forwarded-Prefix, for example /analytics. The collector uses it as the cookie path. Without the header it assumes /_td.

nginx

location /_td/ {
    proxy_pass         https://t.trustdata.tech/;   # the trailing slash removes /_td/
    proxy_set_header   X-Forwarded-Host  $host;
    proxy_set_header   X-Forwarded-For   $proxy_add_x_forwarded_for;
    proxy_set_header   X-Forwarded-Proto https;
    proxy_ssl_server_name on;
}

Caddy

handle_path /_td/* {
    reverse_proxy https://t.trustdata.tech {
        header_up Host {upstream_hostport}
        header_up X-Forwarded-Host {host}
    }
}

For other web servers and CDNs, apply the same six rules from the list above.

Test the proxy

Select Test proxy in the Verify the domain section. TrustData sends an empty request to https://yourdomain.com/_td/api/events and reads the collector's reply. The test confirms three things: the proxy reaches the collector, it removes the /_td prefix, and it forwards X-Forwarded-Host.

The test fails in these cases:

  • The proxy answers with a redirect. Use a rewrite or a proxy rule, not a redirect.
  • The collector reads no host. Either the proxy drops X-Forwarded-Host, or the domain is not verified yet.
  • The collector reads a different host than your domain. Set X-Forwarded-Host to your domain.
  • The domain resolves to a private, loopback or link-local address. TrustData tests public addresses only.

Verify the domain before you test, because an unverified domain returns no host.

TrustData also repeats this check once a day for every verified reverse proxy domain. The result appears under the Tracking domain section as Last check passed or Last check failed. If the check fails twice in a row, TrustData raises a critical alert named Reverse proxy broken for your domain. The alert closes when a later check passes.

Update the install code

After the domain is verified, Installation code on the attribution ID page uses your domain. For a reverse proxy it loads the script from /_td/t.js and sets apiHost to /_td. Copy that code to your site.

<script src="/_td/t.js"></script>
<script>
  trustdata.init('ATTRIBUTION_ID', { apiHost: '/_td' });
</script>

The paths are relative, so the apex and www hostnames both work. Events that arrive on your verified domain without an attribution_id are assigned to the attribution ID that owns the domain.

Troubleshooting

Returning Safari visitors count as new after 7 days. The proxy does not send X-Forwarded-Host, or you use CNAME mode. Add the header or switch to the reverse proxy.

Every visitor shows one location or one IP address. The proxy does not send X-Forwarded-For. Events still arrive.

No cookie is set. The event carried no analytics consent, or the proxy removes Set-Cookie. The collector sets the cookie only with analytics consent and only on a verified domain.

Verify DNS fails. The record has not propagated yet, or its value is wrong. In reverse proxy mode, check the TXT record at _trustdata-verify.yourdomain.com.