It’s a bit late for a New Year’s-themed post and a bit early for a spring cleaning-themed post, but it’s never a bad time to get your Google Analytics data cleaned up. For those of you looking to do just that, here’s a “Quick Fix” checklist to put yourself on the path toward usable data.
1. Identify and resolve self-referrals
A “self-referral” is a visit for which the referring source is your own website. Self-referrals prevent you from seeing the original, valid referral information for the visits in question, so if you’re measuring ROI on advertising outlets, paid search placements, or offline campaigns, it’s important to reduce self-referrals to a minimal level.
First, make sure that every single one of your pages is tagged. This can lead to situations where self-referrals occur.
Many self-referrals are a symptom of deploying Google Analytics without customizing your tracking code to track across subdomains (like blog.yoursite.com) or top-level domains (yourshoppingcart.com). Fortunately, this customization is fairly simple and easy to complete.
When a visitor to yoursite.com navigates, for example, to blog.yoursite.com or yourshoppingcart.com, GA’s default behavior is to set new cookies on the user’s computer, causing yoursite.com to appear as the referring website to a new visit that starts on the new subdomain or top level domain. However, by adding the following simple customization to your Google Analytics tracking code, you can ensure that GA preserves the pre-existing set of cookies, and therefore the original referral information persists throughout the entire visit.
For tracking across top-level domains:
On your first domain (yoursite.com), add the following to your tracking code before the trackPageview() call (obviously replacing “yoursite.com” with your own domain):
pageTracker._setDomainName("yoursite.com");
pageTracker._setAllowLinker(true);
pageTracker._setAllowHash(false);
pageTracker._setDomainName("yourshoppingcart.com");
pageTracker._setAllowLinker(true);
pageTracker._setAllowHash(false);
Now, for every link that you have on either domain that sends a visitor from one domain to the other, add the following bolded code:
<a href="http://www.a-different-domain.com" onclick="pageTracker._link(this.href); return false;">
If you have forms that submit across top level domains, you’ll need to add the following bolded code to each of those as well:
<form action="http://www.a-different-domain.com/form-processor.php" onsubmit="pageTracker._linkByPost(this);">
For tracking across subdomains:
This is MUCH easier than the above. All you need to do is add the following line of code to your tracking code that appears on all your pages, regardless of the subdomain they’re on, again making sure that it goes above the _trackPageview() call:
pageTracker._setDomainName("yoursite.com");
For both subdomain AND top level domain implementations:
Lastly, you’re going to need to set up a filter to apply to each of your profiles so that you can see which (sub)domains your visitors are viewing in your content reports. To do this, you’re going to create an Advanced Filter like this:
Filter Type : Custom filter > Advanced
Field A : Hostname Extract A : (.*)
Field B : Request URI
Extract B : (.*)
Output To : Request URI
Constructor : $A1$B1
To illustrate what this filter does, let’s say that you have an “index.php” on both www.yoursite.com and blog.yoursite.com. By default, Google Analytics will take all the pageviews for “index.php” and aggregate them on one line of data in your content reports. The problem here is that you want to be able to distinguish between those two URI’s, because they are NOT the same! The filter above will take “index.php” and prepend the hostname to it, so you’ll end up with TWO rows of data in your content reports: “www.yoursite.com/index.php” and “blog.yoursite.com/index.php” – and now you can see who’s viewing what pages.
Note that this will change the URI’s that Google Analytics stores, and if you have goals configured to match your old URI’s, you must update those goals once you’ve applied this filter.
With this customization in place, you’ll eliminate one of the biggest sources of self-referrals. Here’s an example of how you’ll benefit. Let’s say you’re running a Google AdWords campaign. You’ll now be able to track your AdWords visitors (and spend) end-to-end on your site, without the risk of losing track of them due to self-referrals. This is critically important for evaluating and improving the performance of any source of traffic.
2. Track all your goals
This sounds basic, but a very large proportion of Google Analytics users don’t track any goals at all, and most GA users that do track goals will only configure one or two. Now that you can have up to 20 goals per profile, you should be tracking every single goal you can think of. To do this, have a brainstorming session and write down every reason you have a website. For example, if you run an e-commerce website, your shopping cart will most likely be your most important goal, but what about tracking goals like these?
- Newsletter sign-ups
- Email to a friend
- Buttons to bookmark/subscribe
- “Contact us” submissions
- Internal search
You could also track goals such as video views, specific content views, social media interaction, RSS feed clicks, blog comments left, and literally hundreds more. Using new “threshold goals,” you can even track time on site and pages per visit as goals.
It’s important to measure all of the value that your site provides. These “microconversions” will give you a fuller view of the performance of your marketing efforts, which will in turn help you make better decisions.
3. Tag your campaigns properly
Tagging campaigns properly is critically important if you plan to use Google Analytics to evaluate the performance of your various marketing efforts. Without proper tagging, it’s nearly impossible to use Google Analytics to evaluate the performance of marketing channels like:
- Yahoo! Search Marketing, Microsoft adCenter and other SEM platforms
- Banner ads, text ads, and other paid placements
- Offline media like print, television, radio, direct mail, billboards, etc…
You can very easily link your AdWords and Analytics accounts and have Google auto-tag your AdWords campaigns for you, but for any other marketing channel, you’ll need to get your links tagged yourself. We recommend that you develop standardized naming conventions before you start to tag or re-tag your campaigns; this will promote consistency and minimize confusion and headaches down the road.
For example, for paid search campaigns, will you use “cpc” or “ppc” as your medium? For campaign names, will you use flight dates (“feb2010”), target audiences (“nascardads”) or something else? Once you have a naming convention in place, you can use Google’s free URL Builder to input your tagging parameters and get your campaigns set to go. Of course, you can always tag your links manually too. In either case, here’s what a properly tagged URL might look like for a Yahoo! Search Marketing ad:
http://yoursite.com/?utm_source=yahoo&utm_medium=cpc&utm_campaign=widgets&utm_content=smallwidgets&utm_term=little%20widget
Notice that we’ve defined the source of the traffic (“yahoo”), the medium (“cpc”, denoting cost per click), and the name of the campaign (“widgets”). We’ve also used the optional parameters content (“smallwidgets”, which in this case is the name of the adgroup) and term (“little widget”, in this case the keyword we were bidding on).
IMPORTANT: Third party tracking mechanisms or URL shorteners often strip out these parameters, so make sure that any redirects that occur before a user reaches your landing page accept query string parameters. If you click on your own ad and you end up at a URL like the above, you’re all set.
Cleaning up self-referrals, tracking all of your goals, and tagging your campaigns correctly will help you quickly get more accurate and actionable data in your Google Analytics reports.
For more tips, tricks, and strategies, bookmark our blog, follow us on Twitter or attend one of our Google Analytics & Website Optimizer Seminars!
Nick Iyengar
Nick is a senior analytics and web intelligence analyst with WebShare. You can find out more about Nick here.
See more posts by Nick Iyengar









I just want to point out an exception to your advanced filter tip, since I’ve seen it improperly used before.
“The problem here is that you want to be able to distinguish between those two URI’s, because they are NOT the same!”
This is not always the case. If you do not redirect your domain.com traffic to http://www.domain.com (or vice versa,) you will have diverging entires in your content reports for the same page. This also goes for any localized subdomains, or situations where sub.domain.com/article1 is effectively the same content as http://www.domain.com/article1, so that your /article1 numbers are combined.
Google still records the original domain, so you can look at the “hostname” dimension on a single content report, or use advanced segmentation to break out traffic by domain if you do localize your visitors.
Also note that this filter breaks site overlay functionality.
I’m forwarding this to our store vendor. We need to get that working. Thanks David!
Don’t give me too much credit, Nick wrote this one!
Danielle – you’re correct in that a www and non-www version of the same domain are treated as unique hostnames in GA, however, most would agree that you should pick one and 301 redirect the other. In a situation where you have localized or regional subdomains, you’ve likely done that because the content is localized and thus different. You can use event tracking or custom variables in order to achieve content groupings, or even more simply you can use inline filters on content reports to get aggregate statistics across a subdomain in the scorecard. With the API a slew of other options are open to you.
Generally speaking, I’d rather have more data and be able to aggregate than not have access to the data needed for granular analysis. Also, remember that advanced segments are applied at the session, and not pageview level like profile filters are.
Lastly, just about everything breaks site overlay ;-), and site overlay, as implemented currently, is fundamentally flawed even when it does work. For true click mapping, try Crazy Egg or ClickTale.
Thanks for the article. I’ve been trying to track my Yahoo Search Marketing in Analytics using {OVKEY} as the term in urlBuilder to identify the keywords from yahoo. However, in Analytics, only “{ovkey}” is displayed in the data, instead of the actual keyword.
Anyone have any tips to get Google to recognize and track Yahoo keywords in Analytics?
Here’s more info on Y!SM tracking URL’s – there’s info about turning this feature on / off and troubleshooting at the bottom. Hope this helps!
http://help.yahoo.com/l/us/yahoo/ysm/sps/screenref/16897.html
Re: Campaign Tracking
I recommend that people keep an Excel sheet of all their campaign tracking conventions to ensure that they remain the same over time.
Even better for collaboration is a Google Spreadsheet ;-). And even better than that would be building your own application that members of your organization can all use to automatically pre-populate based on business needs and let the users select values rather than type them freeform – this helps control options and helps keep data clean!
Thanks for the article and good advice.
Goal tracking should be one of the most straightforward aspects yet many people do not do it. They merely set up Google Analytics and leave it, just looking at the big numbers (or not so big in many cases) on the dashboard.
Self-referrals are a big problems for some GA users. I’ll keep this in mind.
One thing we always seem to repeat to people is to properly tag their email campaigns. It’s easy as pie and adds so much to their GA data.
Hello, I’m having trouble with the self-referral.
Regarding tracking across subdomains,
Your article says to set this:
pageTracker._setDomainName(“yoursite.com”);
and set
Constructor : $A1$B1
in filter
I set mine as
pageTracker._setDomainName(“yoursite.com”);
Constructor : /$A1$B1
As suggested by another article. Do you think this was the problem?
I spent many hours searching for solution. Thanks for your help!
I’ve been doing conducting a sizeable quantity of research on direct online marketing for a brand new page that i will be working on and merely felt like saying that you website is quite rock solid. Thank you for the topical answers you have put together.
It should be pointed out that GA won’t allow goals setup on events yet. The bonus of using events instead of virtual page views is not bloating your pageview counts. Is there any word of Google implementing goals based on events in the near future?
Maggie, thanks for the comment, and apologies for the delay in getting back to you! Your previous filter would simply have added an additional / to your reports, so that your content reports would have displayed URLs like this: http://www.example.com//index.html.
This probably wasn’t the source of your issue. If you are having trouble tracking across domains or sub-domains, leave us another comment letting us know.
Nick