# Cross-domain and subdomain measurement

Subdomains of one business are counted as a single visitor with no configuration at all. Separate domains are not — for those you fill in the domain list, so the linker carries the visitor ID along with the click.

## Two different problems

When a visitor moves from one of your addresses to another, two things can break:

- **The ID is lost**, and one person is counted as two users.
- **The marketing touch is overwritten**, and the campaign that actually brought them is replaced by "referral from your own site".

The fix differs depending on whether the destination is a subdomain of the same domain or a completely separate one.

## Subdomains: nothing to configure

At startup the tracker finds the widest domain the browser will let it write a cookie on, and writes its cookies there. For `shop.example.com` that domain is `.example.com`; for `shop.example.co.uk` it is `.example.co.uk` — browsers reject public suffixes like `co.uk`, and the tracker probes from the outside in.

The result is that all three cookies below are shared across every subdomain:

| Cookie | Holds |
| --- | --- |
| `__sov_did` | the anonymous visitor ID |
| `__sov_ft` | the first touch (source, medium, campaign, landing page) |
| `__sov_lt` | the last touch |

So someone going from `www.example.com` to `shop.example.com` stays one user, and their first touch is untouched. The linker deliberately does nothing in this case: if the root domain of the origin and the destination match, no parameter is added to the link.

> **The touch cookies are tied to marketing consent**
>
> `__sov_ft` and `__sov_lt` are written only when the visitor has accepted the "marketing" category. If they have not, attribution is not lost — the server keeps a durable first and last touch per anonymous ID and substitutes it.

## Separate domains: the linker

Between `example.com` and `example-shop.ir` there is no shared cookie, and no browser will let you create one. Like every other tool in this space, AdPix carries the ID with the click itself:

- You register the list of your business's domains on the data stream.
- The tracker fetches that list with the property configuration.
- When a visitor clicks a link whose hostname matches one of the list's conditions, the tracker appends `_apx=<id>.<timestamp>` to that URL.
- The tracker at the destination reads the parameter and adopts that ID as the visitor ID.

The parameter is valid for two minutes and the ID's shape is validated, so a hand-made `_apx` someone drops into a URL is not accepted.

## Fill in the domain list

1. Open **Admin** in the console.
2. Under the **Property** column, select **Data streams** and open your web stream.
3. In the **Events** card, select **Configure your domains**.
4. Under "Include domains that match the following conditions", add one condition per domain: choose the **match type** and enter the **domain**.
5. Select **Save**.

The stream's own domain and the property's main domain are internal automatically; you do not need to add them again. What you enter here are the **other** domains of the same business.

### Match types

| Match type | What it catches |
| --- | --- |
| Exactly matches | that hostname, any of its subdomains, and any host on the same root domain |
| Contains | the hostname contains the string anywhere |
| Begins with | the hostname starts with the string |
| Ends with | the hostname ends with the string |
| Matches regex | the hostname matches the pattern |

**Exactly matches** is almost always what you want and is the safest, because it already covers subdomains. If you write a regular expression that does not compile, Save comes back with a validation error and nothing is stored.

> **Keep 'Contains' narrow**
>
> A Contains condition with a short value like `shop` treats every hostname containing that string as internal — including other sites that genuinely are sources of your traffic. The effect is that their traffic disappears from the acquisition report and falls into Direct.

## The same list also neutralises self-referrals

The domain list does two jobs, and the second matters more than the first.

Each time an event arrives, the collector looks at the referrer. If the referrer is the page's own root domain, or matches one of the conditions in this list, that touch is demoted from referral to direct, and the real last touch is then restored from the server's durable memory. So the campaign that brought the visitor to the first domain keeps its credit on the second one.

This happens server-side, not in the browser. Even if the linker fails on a particular click for any reason, your own domain still never appears in the acquisition report as an external traffic source.

## What breaks the linker

Check these before filing a bug:

- **Marketing consent was not granted.** Carrying the ID across domains sits under the marketing category. Under opt-in, the parameter is not created until the visitor accepts it.
- **The link is not an `<a href>` tag.** The tracker acts only on a real click on a link. Form submits, `window.open` and `location.href` redirects get no parameter; there you have to build `_apx` yourself or turn the path into a link.
- **More than two minutes elapsed.** If there is a slow interstitial between the click and the destination page, the parameter expires and the destination ignores it.
- **The tag is not installed on the destination domain, or uses a different measurement ID.** Continuity means one visitor within one property; two separate properties produce two separate reports.
- **A click very soon after page load.** The domain list arrives with the property configuration. On a browser's very first visit that list may not have arrived yet; from the next visit onward the cached copy is available immediately.

## Test it

1. Open a page on the first domain with an empty cache, and if you have a consent banner, accept everything.
2. Click a link that goes to the second domain.
3. Look at the destination's address bar: you should see `_apx=`.
4. In the console, open **Realtime**. You should see one active user, not two.
5. Tomorrow, open the **Traffic acquisition** report and confirm your own domain is not in the source list.

If step three shows no parameter, the problem is the domain list or consent. If the parameter is there but step four shows two users, the two domains are not on the same measurement ID.

What "the same visitor" means exactly, and how the server stitches these IDs together once a user signs in, is covered in [How AdPix identifies visitors](concepts/foundations/how-adpix-identifies-visitors).

## Frequently asked questions

### Do I need to configure anything for subdomains?

No. The tracker writes its cookies on the widest domain it is allowed to set, so shop.example.com and www.example.com see the same visitor ID and the same first touch. The only reason to add a subdomain to the list is if it conflicts with another condition.

### The _apx parameter stays in the URL — can I remove it?

AdPix does not strip it from the address bar. It is harmless and valid for two minutes only, but if it bothers you, remove it on your own site after load with history.replaceState — by then the destination tracker has already read it.

### Why do I still see myself as a "referral" even though I added the domains?

First check the link is a real <a href> tag; the linker does not add the parameter to form submits, window.open or JavaScript redirects. Then check the visitor accepted the "marketing" category — carrying the ID across domains sits under it.

### What if the second domain has its own separate property in AdPix?

Then cross-domain measurement is meaningless. Continuity means one visitor within one property, so both domains have to run the same measurement ID and be listed on the same stream.

## Related

- [Data streams](https://docs.adpix.io/en/analytics/collect/data-streams/)
- [Traffic acquisition](https://docs.adpix.io/en/analytics/reports/traffic-acquisition/)
- [How AdPix identifies visitors](https://docs.adpix.io/en/concepts/foundations/how-adpix-identifies-visitors/)

---

[Docs](https://docs.adpix.io/en/analytics/collect/cross-domain-and-subdomain/) · AdPix
