By: Katie Hill

Date: September 6, 2016

The importance of a strong foundation

The unfortunate truth to owning a Google Analytics account is that in order to get clean data, you have to work at it. While you’ve taken the right step in adding Google Analytics to your website, just remember it’s the first step. Many are unaware of the hidden shadows of Google Analytics and are reporting monthly metrics that include traffic from the likes of Russian Viagra companies or campaign testing from your co-worker down the hall. All of this activity can severely affect the integrity of your data.

In this three-part series, we will peel back the hidden layers of Google Analytics to ensure that the data being returned is what is intended. We will discuss foundational set up, blocking unwanted referrals, and ensuring extraneous pieces of data are displayed in a valuable way.

As with anything, building a foundation is the first and most important step. Without a steady foundation, any future business decisions made from your data will be decided on shaky ground. Therefore, it’s important to confirm that your Google Analytics tracking code is setup correctly and you have the right Views in place.

1. Tracking Code Setup

If your tracking code is dated, broken, duplicated, or placed on your site incorrectly, you could be collecting bad data.

  • Dated tracking code:
    Since Google innovates at lightning speed, they generally fall behind when it comes to updating their documentation which results in misleading instructions. It’s entirely probable that you’ll see references to ga.js, analytics.js and Google Tag Manager (GTM) when looking for instruction on how to implement the correct tracking code. These are all different types of tracking mechanisms that Google has offered to track your site and pull data into your Google Analytics profile.
    Prior to 2013, everyone used the ga.js code. However, in May of 2016 Google expired the ga.js code and introduced Universal Analytics, which is now called analytics.js. To add another layer of confusion, Google also introduced Google Tag Manager. In this case, instead of adding analytics tracking code directly to your website, you manage Google Analytics via Google Tag Manager (GTM).
    Make sure you are using the universal.js or GTM code on your site moving forward.
  • Broken code:
    Most of the time, if you copy and paste the tracking code on your site with a missing character, you’ll know pretty quickly when you don’t see any data come through your profile. However, if you or a vendor of yours has customized the code for advanced purposes like or custom dimensions, the risk of getting unwanted data is higher.
  • Duplicate Code:
    This happens more often than you would think. Either someone new to the website forgot to check if there was existing tracking code on the site or, more likely, there is a plugin that you’re using that has inserted the code on your website without you knowing. Duplicate code can result in double the traffic and often will return invalid 0% bounce rates.
  • Placement:
    Another misnomer is placing your tracking code in the footer. While this will still track data, those with a slow internet connection may not be included in your data set if the rest of the page needs to load first. By the time the user clicks to another page, Google Analytics will not have had a chance to load, consequently missing out on a user session. Placing your embedded tracking code just above the </head> tag will give you the best data.

Solution: Ensure you have the correct tracking code on your site, located in the header of your page, with minimal customizations.

To verify you have the correct set up, right-click on your homepage and select “View Source.”


Use your browser’s search function to search the page source the terms “UA-” and “GTM” separately.

If you find GTM, it means you are using Google Tag Manager. As long as you don’t have extensive customizations within your GTM account, it’s likely that Google Analytics is set up correctly on your site. Your code will look something like this:


If you find UA-, your code will look something like the image below. Be sure you only see one instance of this code on your site and that it is placed above the tag of your code. It’s also a good idea to double check that the UA tracking code matches the code for your Google Analytics account.


You may see there are a couple additional lines of code on your site, compared to the example above and as seen below. This is an example where your code has been customized for various reasons like cross-domain tracking or adding custom variables. If you’re suspicious about the data that you are collecting, this might be a good place to direct your developer to ensure you have the right set up.


If you don’t find either reference to “UA-” ot “GTM” , it means you don’t have Google Analytics set up or it’s only set up on certain pages, not your whole site. I’d recommend following Google’s instructions on adding new tracking code to your site.

2. Filter out unwanted test traffic

Once you verify that you have the right tracking code on your site, the next big data offender is YOU (and your colleagues and vendors). If you’re in charge of managing your website, think of all the activity you produce on your own website in a day: how many clicks, how long you linger on pages, how many test purchases or lead form conversions you’ve made, or how many times you’ve tested email campaigns. Your colleagues and vendors are doing the same thing every day. This adds up pretty quick and will alter valuable data you are basing important business decisions against.

Solution: Set up a filtered View to exclude traffic from certain IP addresses.

The best way to avoid unwanted test traffic is to set up multiple Views in Google Analytics so you can filter traffic out by IP address. Views are just another way to look at your data based on the parameters and filters that you set.

When setting up Views, it’s imperative that you keep the original default View that is called “All website data.” Tip: Change the name of “All website data” in the View settings to “Raw Data – Do Not Touch” to make it clear to others who share the account. Having one View that is pure data will come in handy when you need to troubleshoot things in the future.


Once you’ve marked the original raw data View as such, it’s time to set up a new view to apply filters to. Under the View dropdown in your Google Analytics settings, click “Create New View” and give it a new name. I usually make a note in the title that this is the “filtered” View.

Under your new “View” select Filters.


Now, describe what you are filtering out in the “Filter Name” and select Predefined > Exclude > traffic from the IP addresses > that are equal to. Tip: Any easy way to figure out what your IP address is to type is “What is my IP” into google.


If you have multiple IP addresses in your office, you can use the same filter, but use regular expressions for the filter pattern. As you can see in the example below, multiple IP addresses can be separated with pipes (|), but it’s important to precede each dot with a backslash so that it’s treated as a regular full stop.


A couple things to note when you set up views and filters:

  • You can have up to 25 views per property.
  • It takes up to 24 hours for filters to be applied to views.
  • Data is not retroactive. You will only see data in your view starting from the date it was created. If you need to run comparisons on data from before that date, you’ll want to use your “Raw Data” view and run specific custom segments to filter out specific IPs.

Now, when you’re ready to report on your new filtered data, just be sure you’re looking at the right view. You’ll see the name of the View you’ve selected in the top left corner of the page.


For most, just getting these quick foundations in place will produce cleaner, more accurate data. The correct tracking code will ensure you’re receiving valid data for your website. Creating multiple Views, one master and one or more filtered Views, allows you to modify the data you are viewing in order to discard the data that is not valuable to you.

Next up in our data integrity series, we’ll peel back one more layer and take a look at unwanted referrals that can sneak into your data set and how to eliminate them.

Subtext is a digital agency that focuses on building and optimizing online customer experiences for our clients. To learn more about how we help our clients and how we can help you, please get in touch. We’d love to hear from you!