7
Google Analytics Showing My Site as Top Referrer
Google Analytics
Tags: Google Analytics
Share
Update (Feb. 1, 2010) – Important:
After speaking to a few people regarding this issue, some other situations where this will occur have come to light.
First (most important), make sure you tracking code is installed properly on every page of your site. If you use cross-domain tracking or sub-domain tracking, install it correctly on every page of the site.
Second, do not mix the asynchronous tracking code with the original synchronous tracking code on the same page. This WILL result in tracking anomalies. Also, if you mix them on the same site but different pages, make sure they do the same thing. In other words, if one is set for cross-domain tracking, the other should be as well. And, finally, if you use third-party tools that incorporate GA tracking like some shopping carts, install the original tracking code unless specifically instructed to install the asynchronous code.
I began to notice that my own site, jensbits.com, is listed as the top referrer in Google Analytics. This did not seem to be correct since another site I managed had no such issue. And, I also determined that this began right after certain date, in my case, August 10, 2009. So I began to investigate.
What happened on or about 10 August 2009? I put a post on my site that day that has proven to be quite popular. In that post, there is a link to a demo. When I originally posted the demo link, I typed in an absolute URL of http://jensbits.com/demo/forms/index.php for the link’s href. Notice the missing ‘www.’ And, that was the culprit. Eventually, I went through my site to standardize my links and replaced all absolute paths with relative paths. It turns out, however, that loads of people apparently bookmarked the demo and were hitting it directly.
The cookies set by Google Analytics for the http://jensbits.com link had a host parameter (value) of ‘.jensbits.com.’ The cookie also had a correct referrer of (direct). So far so good. All is correct.
The demo page has a link on it to return to the post. That link is relative and it points back to the WordPress post. WordPress will correctly rewrite the URL to include the ‘www.’ The demo link was not a WordPress post so it did not get rewritten. After clicking on the ‘return to post’ link and looking at the cookies again, I now have double the cookies for my site. One set of cookies has ‘.jensbits.com’ as the host value and the other set has ‘www.jensbits.com’ as the value.
The cookies set by Google Analytics for the http://www.jensbits.com link had a referrer of jensbits.com. Correct, but incorrect.

The solution was to fix the canonicalization of the URLs. In other words, all the URLs had to resolve to either jensbits.com or www.jensbits.com. I choose www.jensbits.com since WordPress was doing such a fine job for my posts.
Once the rewrite fix was in place, I have the correct amount of cookies and the correct referrer for the site when I retrace my steps from the demo link to the main site just as I did previously.

Don’t expect to see a precipitous drop off in the referrer number for your site once you institute this. It will decrease over time. Look for a trend, not a miracle. Google Analytics cookies have a lifespan. Return visitors may still carry erroneous cookie data like an albatross around their necks until it eventually dies a natural death.
BTW, the other site I mentioned, I had long ago put in a rewrite rule to include the ‘www’ because of a programmatic session cookie issue with a web-based application. It was my determination at the time that is was specific to the way the programming language I was using was setting cookies.
One other thing to consider: If you are the site owner and/or webmaster, you should put a filter into your Google Analytics profile that prevents your visits from being entered into the reports. An IP address filter is the preferred method to accomplish this.
Note: This is not a WordPress issue. This can happen to any site that will resolve to with or without the ‘www’ in the URL.
Recommended Reading
If this post helped you out, please consider donating to help pay the hosting fees. 100% of the donations go to the web host.
No related posts.
7 Comments for Google Analytics Showing My Site as Top Referrer
Good catch! I know Omniture allows you to enter in both variations or a list of sites to count as internal. It's odd that google would not.
-Rudi
Tweets that mention Google Analytics Showing My Site as Top Referrer - jensbits.com -- Topsy.com
January 7, 2010
[...] This post was mentioned on Twitter by Rudi Shumpert, jen. jen said: New Post: Google Analytics Showing My Site as Top Referrer on jensbits.com: http://bit.ly/8ISfe9 [...]
Very odd that google would not. Also, it's confusing when you use the setDomainName function. It just makes you think you are setting the domain name for the cookies correctly. But, as google says in the setDomainName definition "By default, the method is set to auto, which attempts to resolve the domain name based on the location object in the DOM." Ah ha. The cookie then is set as the fully-qualified domain name and ‘jensbits.com’ is fully-qualified for http://jensbits.com and ‘www.jensbits.com’ is fully-qualified for http://www.jensbits.com. BINGO. Mismatch. I have my setDomainName set to ‘none’ because I use cross domain tracking and I still had this issue.
[...] Here is the original: Google Analytics Showing My Site as Top Referrer – jensbits.com [...]
William Haun
January 7, 2010
What can you say? You're a great self-promoter!
@William
Yea, from me, to me, and back to me. Me, me, me.
Haha, interesting that it was just a matter of changing the blog settings like that. I've had the same thing happen, like why is my own site referring to my own site? But that makes sense now, it's a different url and cookie
- Chris
Leave a comment
« Passed the ColdFusion 8 Certification Exam | Pop-up Survey with jQuery UI Dialog »

Rudi Shumpert
January 7, 2010