Solving Google Analytics Self-Referral Issues

IMPORTANT: This is a historical post from 9 October 2012, please check out our updated version, written in 2016.

If your website spans multiple domains or sub-domains, you might see your own website within the Google Analytics referrals reports. This is called self-referrals and generally indicates that you need to adjust your tracking code to correctly track visitors as they travel between your domains.

If you have already modified your code for cross-domain tracking and you still receive self-referral traffic, some of your pages are likely missing tracking code or your cross-domain tracking code is not correctly installed.

Let's look at how your tracking code needs to be setup to remove self-referral issues from your Google Analytics reports.

The Problem

With self-referral traffic you lose conversion attribution. For instance, when a visitor comes from an advertisement, travels to a subdomain of your site and completes a goal, a self-referral will incorrectly attribute how the visitor arrived to your website. This makes proper analysis difficult.

This occurs because when a visitor travels between domains (or subdomains) without the proper tracking code, a new session is tracked by Google Analytics. This will also inflate your visit numbers inside your reports.

Solving Self-Referral Issues with Cross-Domain Tracking

In order to properly track visitors you need to ensure your tracking code is correct. We will look at two common scenarios, first, we will look at tracking visitors across multiple domains and then we will look at tracking visitors across different sub-domains.

Multiple Domains

One of the ways to examine which pages are missing tracking code is to log into Google Analytics and navigate to Traffic Sources > Sources > Referrals. Then enter your site URL in the search box. If your website appears in the results, you have a self-referral. Click on it and select 'Landing Page' as a 'Secondary Dimension'. Now you should be able to see which pages your self-referrals are coming from in the 'Landing Page' column.

To properly track visitors traveling from to, you need to make modifications to the tracking code on both sites. Basically, you need to transfer the cookies from one site to the other when a visitor travels between the domains. This helps to maintain the correct cookies and visitor information on all the domains.

In order to transfer the cookies, you need to make modifications to all the links directing people to other domain. For example, if a visitor is on and clicks on a 'Buy now' link that directs to, you will need to modify links appropriately:

<a href=""

onclick="_gaq.push(['_link', this.href]);return false;"

> Buy now

If the visitor can travel from to using a form, then the form code on, needs to look like this:

<form action="" method="post"

onsubmit="_gaq.push(['_linkByPost', this]);"



Tracking code on

var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-123456-1']);

_gaq.push(['_setDomainName', '']); _gaq.push(['_setAllowLinker', true]);

_gaq.push(['_trackPageview']); etc...

Tracking code on

var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-123456-1']);

_gaq.push(['_setDomainName', '']); _gaq.push(['_setAllowLinker', true]);

_gaq.push(['_trackPageview']); etc...

Multiple Sub-Domains

If your website uses multiple sub-domains (e.g.,,, etc.) and your visitors move between them, different tracking cookies will be created on each subdomain. This means a visitor will not be recognised as the same visitor traveling between sub-domains and the main domain.

To fix this issue, a tracking code (like the one below) should be placed on the main domain and all sub-domains:

var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-123456-1']);

_gaq.push(['_setDomainName', '']);

_gaq.push(['_trackPageview']); etc...

The _setDomainName() function defines which domains you should enable cookie access for any sub-domain.

The links to and from the main domain to the sub-domains do not need changes because the sub-domains are now setup to share the same cookies.

Once you have proper tracking code on all domains and sub-domains, your Google Analytics account will accurately track bounce rates, visits and attribution.

NOTE: The sample code provided in this article uses the Google Analytics asynchronous ('async') tracking code.