AdWords is now Google Ads. Our new name reflects the full range of advertising options we offer across Search, Display, YouTube, and more. Learn more

5.6K members online now
5.6K members online now
Dive into multiple domain (Cross/Sub) tracking, implementing Ecommerce and Enhanced Ecommerce, setting up Event tracking, and Universal Analytics code.
Guide Me

Avoiding Self Referrals in Universal Analytics?

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

I'm getting a lot of referral traffic listed with my own domain name in my Google Analytics tracking reports. I'm running the same Universal Analytics tracking code on multiple subdomains for the same domain.

The tracking code (with placeholders for the Analytics account and domain name) is like this (for all the subdomains, including the www one):


<script type="text/javascript">
          (function (i, s, o, g, r, a, m) {
              i['GoogleAnalyticsObject'] = r; i[r] = i[r] || function () {
                  (i[r].q = i[r].q || []).push(arguments)
              }, i[r].l = 1 * new Date(); a = s.createElement(o),
              m = s.getElementsByTagName(o)[0]; a.async = 1; a.src=g; m.parentNode.insertBefore(a, m)
          })(window, document, 'script', '//', 'ga');

          ga('create', 'UA-1111111-1', {
              cookieDomain: '',
              legacyCookieDomain: ''
          ga('send', 'pageview');


The traffic is getting listed in the report as: / referral


Am I doing something wrong that would result in the referral tracking I'm receiving?


1 Expert replyverified_user

Re: Avoiding Self Referrals in Universal Analytics?

Explorer ✭ ✭ ✭
# 2
Explorer ✭ ✭ ✭
Hi Joe,

1) Look at the www vs non-www, you should only have one version and redirect the other (SEO purposes). Make sure you cannot navigate to both.

2) You likely have a missing tracking code on a page. This can cause a session to restart resulting in a self-referral

3) Check your cross-domain tracking

The last option is to add your domain to Admin > Property > Tracking Code > Referral Exclusion List , this can cause problems if you want to legitimately track traffic from some or all sub domains, but check this article for a fix around this

- Use Full Referrer as a secondary dimension under Behaviour > Site Content > Landing pages to help troubleshoot the self referral

Re: Avoiding Self Referrals in Universal Analytics?

Top Contributor
# 3
Top Contributor
Hi Joe,

you can simplify the code with just using this create line:
ga('create', 'UA-XXXXXXX-1', 'auto'); // this deals with main and subdomains

Some additional questions - is referral exclusion set inside GA property level? Are you sure all pages for all sites are tagged with GA?

Kind regards,
Web analyst @

Re: Avoiding Self Referrals in Universal Analytics?

Visitor ✭ ✭ ✭
# 4
Visitor ✭ ✭ ✭
Hi Bryan,

Thanks for the response. Regarding your points:

1.) I have all pages redirecting to the www version

2.) I'm 99.9% sure that I have the code on all pages of the site. I'll double check that.

Would it matter that I'm defaulting all pages to the www version of the page, but the values I'm setting for cookieDomian and legacyCookieDomain at all times are being set to (instead of