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]);"> etc...

Tracking code on

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

Tracking code on

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

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', '']);

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.

  • dan barker

    Thanks for the post.

    A little caveat that may/may not be useful is that sometimes I see this where cross-domain tracking isn’t the best option.

    An example that seems to crop up fairly frequently is “m.” mobile sites (where a visit from the “www.” to the “m.” looks like a self-referral). Sometimes there the most useful solution is to separate out the “m.” traffic from the main profile entirely, treating them as separateish sites, and allowing to see where they refer to each other.

    • Benjamin Mangold

      Thanks for the comment Dan,

      We would generally recommend going with the same code on the mobile and non-mobile versions of the site and then use advanced segments and/or filtered profiles to then perform analysis and reporting.

      Using filtered profiles you could have the following profiles;

      1) ‘Mobile and Non-Mobile’
      2) ‘Mobile Only’
      3) ‘Non-Mobile Only’

      If you also add the hostname (domain) into the pages report using an advanced filter you can even use the Visitor Flow report to understand visitor navigation.

  • Elmer

    Your article was nice. Thanks for sharing such important information that is commonly seen nowadays. Also, you’ve put some insights on how to solve that problem.
    Google Analytics

  • Van Nes

    This comment has been removed by a blog administrator.

  • Van Nes

    Hello Ben.
    I’m using the _setDomainName parameter, but still see our seb-domain as a referral source. here is the code i use (i’ve copied it and replaced the private info):

    var _gaq = _gaq || [];
    _gaq.push([‘_setAccount’, ‘UA-XXXXXXXX-X’]);
    _gaq.push([‘_setDomainName’, ‘’]);
    _gaq.push([‘_addOrganic’, ‘’, ‘query’]);
    _gaq.push([‘_addOrganic’, ‘’, ‘q’]);
    _gaq.push([‘_addOrganic’, ‘’, ‘s’]);
    _gaq.push([‘_addOrganic’, ‘’, ‘q’]);
    _gaq.push([‘_addOrganic’, ‘’, ‘r’]);
    _gaq.push([‘_addOrganic’, ‘’, ‘text’]);
    _gaq.push([‘_addOrganic’, ‘’, ‘request’]);
    _gaq.push([‘_addOrganic’, ‘’, ‘query’]);
    _gaq.push([‘_addOrganic’, ‘’, ‘q’, true]);
    _gaq.push([‘_addOrganic’, ‘’, ‘text’, true]);
    (function() {
    var ga = document.createElement(‘script’); ga.type = ‘text/javascript’; ga.async = true;
    ga.src = (‘https:’ == document.location.protocol ? ‘https://ssl’ : ‘http://www’) + ‘’;
    var s = document.getElementsByTagName(‘script’)[0]; s.parentNode.insertBefore(ga, s);

    Do you have any suggestions of why this could happen?
    Some possible problems are described here –

  • EdgarPE

    I have the same problem as Van Nes.
    I use the _setDomainName and still see subdomains as referrals. My tracking code is as simple as possible, I just generated it on GA and copy pasted it to the site.
    Every subdomain contains the tracking code, it’s impossible to left it out, because of the CMS system.

  • Alwin Mayer

    While it seems like a minor bit, it’s still annoying when you encounter this, especially when you’re a marketer trying to beat a tight reporting deadline and omitting unrelated items will be detrimental. This will be helpful to avoid such instances in the future.

  • Unknown

    Setting up correct tracking for cross-domain or cross-subdomain, as descrbied above, will make it so the same cookie is used to identify the user across the different sites. It will NOT however, solve the problem of self-referrals- you must use addIgnoredRef for this. See #3 at

  • Niek

    Hi, i still got the same issue!
    We implemented this code:
    [‘_require’, ‘inpage_linkid’, pluginUrl],
    [‘_setAccount’, ‘UA-XXXXXX-1’],
    [‘_setDomainName’, ‘’],
    [‘_setAllowLinker’, true]

    on both subdomains but still we see its as refferal traffic…

    any idea/

  • Global Leadership Adventures

    What about www and non-www. how do I fix that?

  • Global Leadership Adventures

    What about www versus non-www

  • لعبة زوما

    While it seems like a minor bit, it’s still annoying when you encounter this, especially when you’re a marketer trying to beat a tight reporting deadline and omitting unrelated items will be detrimental. This will be helpful to avoid such instances in the future.

  • Loves Data

    Hi Global Leadership Adventures,

    There are a lot of different issues that can crop up with cross domain tracking and tracking of subdomains. Here is a Google support page that addresses a number of these issues. Be aware that this information only applies to the ga.js tracking method.

    Please let us know if you still have issues after going through these solutions.

  • Anonymous

    Just use this command in your tracking code


    • Benjamin Mangold

      This is an option, but it doesn’t actually fix the issue, instead it simply means self-referrals would be reported as direct traffic.

  • Dota

    Is there an update to universal analytics for this topic?