Sub topic 12
Fixing self-referrals with referral exclusions and cross-domain setup
This chapter assumes you can open Admin in a GA4 property, you know what source, medium, and session mean in GA4, and you have Editor access to change data stream settings. You should also have read the earlier chapters on source/medium/campaign and on why traffic appears as Direct or Unassigned.
What a self-referral is
A self-referral happens when a visitor moves from one page you own to another, and GA4 records the first page's domain as the traffic source. The visit then shows up as referral traffic from your own site. In the Traffic acquisition report, a row such as checkout.example.com / referral is a typical sign.
Self-referrals matter because they split one real visit into two sessions. The second session has the wrong source, so the original channel (for example, Paid Search) loses credit. Key events that happen late in the journey, such as a purchase, get attributed to your own domain instead of the campaign that brought the person in.
How GA4 decides a visit is a referral
GA4 reads the HTTP referrer, which is the address of the page the visitor came from. If the referrer's domain is not on the list of excluded domains and the link has no campaign parameters, GA4 sets the source to the referrer's domain and the medium to referral.
GA4 keeps a session going while the visitor stays active, and it starts a new session in some cases. One case is when the visitor arrives with a new traffic source after the session has ended. Another is when the traffic source changes mid-visit. A visit that crosses to another domain can trigger the second case if GA4 treats the move as a new referral.
Two things usually cause a self-referral:
- The visitor crosses to a different domain that you own, and GA4 cannot tell it is the same visitor.
- The visitor leaves for a third-party service and comes back. Payment pages and single sign-on pages are the usual examples.
These two causes have different fixes, so identify which one you have first.
Subdomains
Subdomains of one registrable domain, such as www.example.com and shop.example.com, normally share the GA4 cookie. GA4 sets its cookie on the highest-level domain it can, so a visit between these hosts stays in one session. You do not need cross-domain setup for them.
If you still see a subdomain as a referral, check that every host uses the same measurement ID and that no page sets its own cookie domain. A different measurement ID on one host is a common cause.
Fix 1: Unwanted referrals (referral exclusions)
In GA4 the setting is called List unwanted referrals. Use it for domains whose traffic should not start a new session. These are usually third-party payment and login providers.
To set it up:
- Open Admin, then Data streams, and select your web stream.
- Select Configure tag settings.
- Under Settings, select List unwanted referrals.
- Choose a match type and enter the domain, for example
paymentprovider.com. - Select Add condition for more domains, then Save.
The match types are Contains, Begins with, Ends with, Exactly matches, and Matches regular expression. Contains is the easiest to use. Be careful with broad values: Contains pay also excludes any referrer with "pay" in the name, including real sites such as a blog about payments.
When a referrer matches the list, GA4 does not use it to start a new session. It sets the traffic source as if the referrer were missing, which means the visit keeps the earlier source of the session. This differs from a Direct visit, where there is no referrer and no earlier session.
Changes apply to new data only. The rows already in your reports stay as they are.
Exclude your own domain
GA4 does not automatically exclude the domain of the site you are measuring. Self-referrals from the same registrable domain are handled by the cookie. If you see your own main domain listed as a referral anyway, the likely cause is a missing tag on the entry page or a redirect that strips the session, rather than a missing exclusion. Check both before adding the domain to the list.
Fix 2: Cross-domain measurement
Use cross-domain measurement when you own several domains and want one visit to stay one session as the visitor moves between them. An example is example.com for the main site and example-checkout.com for the cart.
Browsers store cookies per domain, so the second domain cannot read the first domain's cookie. Cross-domain measurement solves this by adding a _gl parameter to links that go between your domains. The parameter carries the client ID, and the receiving page reads it and uses the same ID. GA4 then treats both pages as one user and one session.
To set it up:
- Open Admin, Data streams, and your web stream.
- Select Configure tag settings, then Configure your domains.
- Add a condition for each domain that belongs to the visit, for example
Contains example.comandContains example-checkout.com. - Save.
Both domains must run the same GA4 tag with the same measurement ID. If the second domain uses a different ID, the shared client ID will not help.
What you can verify
After you save, open a link from the first domain to the second. The address on the second domain should include _gl= followed by a long value. If the parameter is missing, check the following:
- The link is a normal
<a>element or a form that GA4 can modify. Links created later by JavaScript, or sent through a redirect, may not get the parameter. - The tag loads before the visitor clicks.
- The domain you typed in the configuration matches the domain in the link.
- A redirect between the two domains does not strip query parameters.
You can also use DebugView to watch the events and confirm that the session ID stays the same across both domains.
Combining both fixes
A checkout flow often needs both settings. Suppose a store on example.com sends the visitor to example-checkout.com, which sends them to paymentprovider.com, which returns to example-checkout.com.
| Domain | Owned by you | Fix |
|---|---|---|
| `example.com` | Yes | Add to cross-domain list |
| `example-checkout.com` | Yes | Add to cross-domain list |
| `paymentprovider.com` | No | Add to unwanted referrals |
Checking the result
Wait for new data, then compare against the earlier period.
- Open Reports, Acquisition, Traffic acquisition.
- Change the primary dimension to Session source / medium.
- Search for the domain that appeared as a referral.
- Compare sessions and key events before and after the change.
You can run the same check through the Data API. This request lists referral rows so you can see whether your own domains still appear:
{
"dateRanges": [{ "startDate": "14daysAgo", "endDate": "yesterday" }],
"dimensions": [{ "name": "sessionSourceMedium" }],
"metrics": [{ "name": "sessions" }, { "name": "keyEvents" }],
"dimensionFilter": {
"filter": {
"fieldName": "sessionMedium",
"stringFilter": { "matchType": "EXACT", "value": "referral" }
}
},
"orderBys": [{ "metric": { "metricName": "sessions" }, "desc": true }],
"limit": 25
}Sessions from your own domains should drop, and Direct or the earlier campaign sources should rise to match.
Common errors
- Excluding a domain you should connect. If you own the domain, add it to cross-domain measurement, not to unwanted referrals. An exclusion hides the referral but does not join the two user IDs, so you still get duplicate users.
- Using cross-domain for a third party. You cannot set up cross-domain measurement with a domain whose tag you do not control.
- Overbroad match rules. Test a Contains rule against the referral domains you actually see before saving.
- Judging the fix too early. The old rows remain, so compare only dates after the change.
- Checking the wrong report. The User acquisition report uses first-user values, so it may not show the change in session sources.
Exercise
Your store runs on shop.example.com. The cart is on securecart.example.net, which you own and tag with the same measurement ID. Payment happens on bankpay.example.org, a third-party site, and the visitor returns to securecart.example.net afterward. Traffic acquisition shows shop.example.com / referral and bankpay.example.org / referral with purchases attributed to them. Which settings do you change, and where?
Show answer
In the web stream's tag settings, under Configure your domains, add conditions for example.com and example.net so the visit stays one session across the two domains you own. Under List unwanted referrals, add bankpay.example.org so the return from the payment site does not start a new session. Then compare only dates after the change.
Exercise
After you add a Contains rule for pay to the unwanted referrals list, a blog at paymentnews.example.org stops appearing in your referral report. What happened and how do you correct it?
Show answer
The Contains match treats any referrer with "pay" in the domain as unwanted, so the blog's real referral traffic is now ignored. Replace the rule with a narrower one, such as Exactly matches bankpay.example.org or Ends with the provider's full domain.