
Beware, Google Analytics users!
Google Analytics is a great free tool that can provide tons of useful insights about how your website is performing, how users are interacting with your content, where you should focus your priorities, and much more.
But before you start making important decisions for your next marketing moves, please – oh, please – make sure you’re working with good data!
You may have already seen some data in Analytics that just doesn’t look right, such as:
- referral visits from sites you’ve never heard of;
- traffic from far-off countries that doesn’t make any sense; or
- huge, inexplicable jumps or drops in traffic.
If you’ve seen anything like this in your Google Analytics account, then you’re very right to be suspicious.
This bad data typically comes from spam bots that surf the web and try to drive traffic to advertising-driven websites that make money based on pageviews. These domains can show up in your Analytics reports, and when you go to visit them to find out what they’re about they make money. Ugh, I know: the internet can be a frustrating place!
Another source of bad data can come from websites that are unrelated to you, but nefariously copy your Analytics tracking ID. You can certainly contact those sites to request that they stop doing so, but often such efforts can be fruitless.
The good news is that there are solutions for these problems. We highly encourage you to take the steps below to ensure that your Google Analytics data is good data!
Step 1: Ensure Analytics Code is in The Right Place
Ideally, Google Analytics tracking code is a snippet of Javascript that fires each time a page on your website is loaded by a user’s browser.
Best practice is to place that tracking code in the <head> section of the source code of each page of the website, which will make sure that the code fires even if the page isn’t fully loaded.
In the past some developers worried that Analytics tracking code would slow the site down, so Google adjusted the code to be asynchronous – meaning that the tracking code loads independently from the rest of the site. So that’s no longer an issue.
If the Google Analytics tracking code isn’t in the <head> section of your website’s HTML page source, you could be missing out on a lot of data. Missing data could cause all kinds of problems such as missed pageviews and distorted user engagement metrics.
How To Check
Open up a few different pages of your website in separate tabs in your browser, then while you’re on each tab hit CTRL + U (for Macs use Command + Option + U) to view the page source code. That should work for most browsers, but here are instructions to do that in the most common browsers.
Then hit CTRL + F (Command + F on a Mac) to find your Google Analytics Tracking ID within the Page Source. If you’re not sure what your Tracking ID is, within Analytics you can navigate to Admin > Account > Property > Tracking Info > Tracking Code. The tracking ID is a unique number for your website that looks like this: UA-000000-0.
Once you’ve found the tracking ID, note the line of the Page Source on the left side of the browser window. In the example below, you can see the tracking ID is at line 79:
Then do another CTRL + F for </head> and note the line number. This is the end tag for the <head> section of the HTML code for your site. If the Analytics code comes before the </head> tag, then you’re in good shape. If the Analytics code is somewhere later in the page source (such as the <body> or <footer>), then it needs to get moved.
The Remedy
If you’re using a WordPress site, the Google Analytics for WordPress by MonsterInsights plugin does a great job of putting the code in the right place, is easy to use, and has some other very useful functionalities to boot.
Otherwise, you may need to ask your webmaster or IT professional to move the code for you.
One very important note: after the fix is in, check to make sure there is only one copy of Google Analytics tracking code on each page of your website. Duplicating the code can cause data issues, and it can also slow down your site’s load times unnecessarily.
Step 2: Make Sure Analytics Code is On All Pages
Google Analytics tracking code only fires on a per-page basis, so if it’s not on every page of your website then you won’t be getting data on visits to those pages. The problem here again is incomplete data.
How To Check
If you’ve got a small website with only a few pages, you may just want to use the View Page Source technique described above.
But if your site has more than a handful of pages, you’re going to want some help. That’s where one of my favorite, awesomely named SEO tools comes to the rescue: Screaming Frog.
The free version of the software will crawl up to 500 URLs, which is suitable for most smaller websites. And if you’re planning on doing some more SEO work, the paid version will come in extremely handy and is very affordable.
Set up Screaming Frog (SF) to crawl your website beginning with the homepage, but before you hit the “Start” button, go to the “Configuration” menu at the top of the window and select Custom > Search. Note that this option is only available in the paid version of Screaming Frog.
There you can set up two searches: one to find all pages that contain your tracking ID, and one to find all pages that do not contain your tracking ID. It’ll look like this:
Then when SF is done with the crawl, check the “Custom” folder in the right-hand pane (it’s towards the bottom). If you don’t have 100% tracking code coverage, click on “Does Not Contain” to see a list of the pages where it’s missing.
The Remedy
If there’s a pattern to the pages missing your Analytics code (e.g., they’re all in one folder or directory of the site), there may be some settings in your Content Management System (CMS) that are preventing the code from showing up there. Some CMS’s have settings for sections of the site (static pages as opposed to blog posts or event listings, for example) that can be adjusted.
Otherwise, talk to your webmaster or IT professional.
Step 3: Back Up Your Data with an Unfiltered View
Google Analytics has “Views” of data which can be configured for a variety of purposes. Basically, a “View” can be set up to only see a particular “slice” of the overall data.
This step involves either making sure that you already have a View that is collecting all data for the site, or setting up a new View that does just that. We need to do this in order to ensure that we have one Analytics View that is collecting all data for the site, just as a backup in case anything ever goes awry.
See What You’ve Already Got
In Analytics, go to the “Admin” section by clicking the gear symbol in the lower left corner of any of the reports. In the “View” column, click the drop-down box to see how many Views you currently have for the site.
If you only have one View (which is most likely the case), then exit the drop-down menu and click the “Filters” option underneath it. Once you get to the Filters screen, if you see an empty box like this…
…then congratulations – you already have an unfiltered View! You can skip to the next step.
If you do find filters listed in the box above, then you are looking at a filtered View. You can click on those filters to see what they’re doing to the data; it’s possible that they may be set up like the filters we’re recommending below so keep on reading if that’s the case.
Also, if this View is not clearly named, you may want to select “View Settings” in the View column of the main Analytics Admin dashboard and name the View accordingly to avoid future confusion on the part of yourself or others.
If you don’t have a View without filters or if you’re not sure what the active filters are doing in the existing View(s), then you need to set up a new unfiltered View.
Creating an Unfiltered View
Go back to the main Admin page using that handy gear icon in the lower left corner of Analytics. In the View column, click on dropdown and select the option for “Create a new view”. Give the View a name like “No Filters”, set the timezone, and click the “Create View” button.
Voila – you now have an unfiltered View!
Step 4: Create a Filtered View
If you’re not sure about the other Views in the account, you should probably follow the steps immediately above to create a new View that’ll be the home for your good data. You can create up to 25 Views per Analytics property, so there’s usually plenty of capacity.
Or if you’re feeling brave you can use an existing View; first you’ll want to check with others in your organization to make sure they’re not using it for some reason. Then remove whatever filters already exist in that View.
One important thing to note is that when you set up a new View, historical Analytics data will not be present in that View. Data only begins to flow into the View the moment it’s created. There are ways to use segments to filter bad visits out of historical data, but that’s a topic for another day.
This new View is the one you’ll want to use to analyze visits to your website going forward.
Step 5: Implement Filters
In our fresh View, we’re going to create the following filters that will rid it of all the most common types of bad, invalid data that make it difficult if not impossible to see what’s actually happening on your website.
To create these filters, go to the Admin section of Google Analytics (remember, it’s that little gear at the bottom left of the Analytics reporting interface). Under the “View” column, click “Filters” and then click the red “Add Filters” button at the top.
Filter #1: Hostname Include Filter
This filter is set up to make sure that only visits to your website are counted in this View. It’ll take care of many of the issues we discussed at the top of this post in one fell swoop. Here’s how we have it set up for our site; obviously you’ll want to change the domain name (example\.com) to your own:
There are two very important details for the “Filter Pattern” field:
a) Only include the root domain (no “www”);
b) Place a backslash (\) (not a forward slash, which looks like this: /) in front of the period that comes before “.com” or “.org” or “.net”. This field functions with regex, and the backslash tells Analytics to treat the period like a period, not like a regex special character.
Filter #2: Internal & Vendor IP Address Filters
The goal of your website is to attract new people to your organization or business, right? It’s their behavior on the site that matters most, correct?
You don’t want your Analytics data muddied up with the visits that you, your co-workers or your vendors (especially external website developers and designers) make to the site.
So we need to set up some filters that exclude visits from these sources. These are going to be Exclude filters based on IP addresses. They’ll look like this:
How do you figure out IP addresses? Easy.
Just make sure you (or your vendors / co-workers) are physically located wherever you/they frequently work on or visit your website – which may be the office, their home, a cafe or coworking space. Make sure you/they are on a device (desktop, laptop, tablet or phone) that’s using the local Ethernet or wi-fi that is usually used to access the internet – not a cell phone signal.
Then either go to WhatIsMyIP.com or click this link to open up a Google search for “what is my ip“ and you’ll get a a string of numbers separated by periods that looks like this: XX.X.XXX.XXX. That’s the number you’ll want to enter into the “IP address” field in the dialogue above.
Sometimes the groupings of IP address digits will be different than what’s shown in the examples here, but you get the idea.
Note that we’re not looking for a MAC address, which can sometimes come up in these tools. If you get a MAC address (the giveaway is that it includes letters), try another IP address tool like this one.
If you have multiple locations / IP addresses to filter out, you’ll need to create a separate filter for each one.
Filter #3: Other Spam Bot Filters
If you want to exclude visits from additional spam bots, you can create a new filter or filters using the following settings:
Note that the filter above relies on regex. So you’ll want to place .* in front of each domain name, and a backslash (\) in front of the period before “.com” or “.org” or “.net” in the domain name. As in the example above, you can use one filter to exclude visits from multiple sites by using the pipe (|) separator.
Put Your Filters In Order
Google Analytics filters work from top to bottom in the order you see them in the Filters page of the Admin section. So it’s best practice to put the broadest filters on top and the most specific ones on the bottom. Luckily, Analytics provides an easy way to do this, namely the grey “Assign Filter Order” button at the top of the Filters page:
Just click on that button and you’ll see that you can select individual filters and move them up or down in the list. We recommend placing them in the following order:
- Hostname Filter
- IP Address Filters
- Other Spam Bot Filters
Phew!
That pretty much wraps it up. By the time you’re done with the steps above, you’ll have established a backup Google Analytics View with all data, and you’ll have a shiny new Filtered View that you can rely on for accurate data going forward.
Just be sure you select that new Filtered View when you’re looking in Analytics reports!
The wonder of digital marketing is having all this data that you can use to both track the performance of your marketing campaigns and inform your decisions on the best places to focus your future efforts. So it’s definitely worth your time to make sure you’re basing all of those important analyses and decisions on accurate data.
Do you have any questions on the strategies presented here? Or perhaps you have a unique situation that wasn’t addressed? If so, leave a comment below or contact us and we’ll be happy to help you out!
Submit a Comment