Identifying and Filtering Internal Traffic from Google Analytics


Filtering out employee traffic remains one of the biggest challenges our clients and training attendees face. Unfortunately, there isn’t just one solution to capture everyone, but we can hopefully catch as much as we can.

There have been many blog posts and articles written about the best ways to identify employees, this blog post will try to round up the best solutions out there and provide code examples when applicable.

Why Is It So Important?

Depending on the size of your company, internal traffic can cause very serious issues in your Google Analytics. Employees don’t act like typical web users and will alter the metrics that are most reported – like users, sessions, and pageviews. Perhaps more importantly, they impact conversion rate and attribution reporting, which can directly impact budgeting, bid strategies, and business decisions.

To effectively filter out as much employee or vendor traffic as possible, you’ll want to take a multi-tiered approach and combine several of the solutions below. How often have you worked from home or traveled with a laptop for business? Have you ever cleared your cookies or used multiple browsers? A smart combination of filters and manual processes will help address all of these issues.

IP Address Filtering

Filtering out employees by IP address is probably the most well-known and certainly the easiest to implement. We’ve talked about it our trainings till we’re blue in the face and started writing about it on our blog over 8 years ago. Here’s the quick refresher:

If your company has a brick-and-mortar location AND a static IP address or address range, you can exclude all traffic to your site that is coming from that IP address. Most large companies will have static IP addresses, which means that we can reliably use these to block traffic coming from inside your office building.

You can find your public IP address by doing a Google search for “what is my ip?” There are other tools out there, but what Google sees is the only thing that matters, as that’s who will be doing the filtering. If you’re not sure if you have a static IP address, you may want to check with your IT department or office manager.

IPv4 address look like the following while IPv6 address look something like 2001:0db8:85a3:0044:1000:1a2b:0357:7337. Google recognizes and supports filters for both IPv4 and IPv6.

Creating Filters

The actual process is pretty simple, but you’ll need to have Edit permission at the Account level to create these filters. Start on the Admin screen of Google Analytics and choose All Filters under the Account dropdown on the left side. This will allow you to apply the filter to multiple Views at the same time.

For a single IP address, you can use one of the default filters and just paste in your IP Address like below:


For an IP address range, you’ll have to select Custom Filters, then choose Exclude, and IP Address from the dropdown list. Then, enter a regular expression for the IP Address range like below:


Filtering by Network Domain

If you’re a really large company, you may even have your own Network Domain. There are few Domain Lookup tools where you can input your IP address from above and see if your company’s name is returned. For smaller companies or individuals, this is usually the name of the service provider.

You can also check this by navigating to your Domain reports in Google Analytics, found under Audience >> Technology >> Domain.

Be careful when creating either IP address or network domain filters to make sure that you’re not filtering out non-employees. A perfect example would be a college or university that has both staff and employees connecting through the same network.

Here’s an example using the Network Domain:


Filter By A Custom Dimension

If you can’t identify an employee by the location from which they’ve connected to your website, you now have to settle for some less-than-ideal solutions. At the heart of the following solutions is the following principle: Identify someone as an employee and store that as a user-level custom dimension, which is then filtered out from your analytics.

Where our IP Address and Network Domain options focused on how a user connected to the internet, this approach focuses on the particular browser and computer that an employee uses to browse your website. Different browsers, different devices, different Chrome profiles will all need to separately identify themselves as employees.

GA Configuration

Custom dimensions are ways to add information to Google Analytics about users, sessions, products, or specific hits. Custom dimensions are only available in Universal Analytics, but they provide us with much greater flexibility and features when compared with their predecessor – custom variables.

In this case, we’ll create a user-scoped custom dimension called Visitor Type and note the index number. For our examples, we’ll continue to use the index number 1, though you’ll need to make sure this matches up with your index number.


By setting this at the user-level, we know that Google Analytics will remember this anytime a user comes back to our site with the same set of cookies, which means on the same browser and device as before.

Now, we just create a filter to look for a certain value in this field, which later we’ll specify as “Employee.”

Identifying Employees

Now comes the hard part – how do we identify employees who are not within our physical location? I’m a fan of all automated solutions, so let’s start with the best options.

Common Page Tagging

Do you have an intranet, employee portal, or common login page that only employees can access? We might as well take advantage of any page where your employees are already self-identifying themselves as employees. If these pages are on the same domain as your website, then we can add tracking to these pages so that every time someone access one of these pages or logs in.

This option works even better if you can force employees to hit this page by setting this as a default homepage through enterprise settings or gifts and bribery.

We don’t normally want to track this as part of website, but in this case, we’ll track a page and then immediately filter it out. Again, if everyone is funneling through ONE page, that’s where we want to put this code. We don’t need to put it on every page on our intranet, just the one that almost everyone will hit.

Same Domain Common Pages

If you access to change the code on the page, you can add a snippet like the following to the page to 1) Set custom dimension #1 to the value of “Employee” and 2) Send a pageview to Google Analytics. Importantly, make sure you’re using the same cookie settings that you’re currently using on your actual site.

<script type="text/javascript">
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
ga('create', 'UA-123456-1', 'auto');
ga('send', 'pageview',{'dimension1':'employee'});

WordPress Options

If your website is based in WordPress, and your employees are frequently logging into your WordPress Dashboard, why not add this to your login page?

Here’s some documentation on how to modify the login page, and a code snippet below that you’ll need to add to your functions.php file. You’ll need to add this somewhere in between the opening and closing ?php tags. Make sure you know what you’re doing though, as server-side updates may have a more serious impact that simple JavaScript additions.

//Adding Login page scripting
function my_login_pageview() { ?>
<script type="text/javascript">
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
ga('create', 'UA-123456-1', 'auto');
ga('send', 'pageview',{'dimension1':'employee'});
<?php }
add_action( 'login_enqueue_scripts', 'my_login_pageview' );

Separate Domain Common Page

If you have a webpage or login that everyone hits, but lives on a separate domain, we’ll have to do some magic here. We want all employees who arrive on this common page to load our website and set a custom dimension identifying them as an employee.

This method isn’t as elegant as other solutions, but we can do the following steps:

  1. Create a hidden page on our site that automatically sets a custom dimension and tracks a pageview
  2. Embed this page inside of an iframe on our common page
  3. Ideally, the iframe would be set to a tiny size like 1px by 1px, and would only load when the person first arrives.

Even though they’re unaware of the process, this will set a cookie on your employee’s browser for your website so the next time they visit your site, they’ll still be identified as an employee.

Voluntary Opt Out Options

If we can’t block access by how someone connects to the internet, and we can’t block access using common pages that your employees will already hit, than our options are shifting from automated processes to manual coercion. The following methods will all require action from employees to voluntarily raise their hand and say, “Hey! I work here! Don’t count me!”

That’s correct: voluntary. We’ll come back to begging and groveling later.

Creating a Opt Out Page

We can create a page that lives on a hidden portion of our site that allows employees to voluntarily opt out of our Google Analytics. Create this page somewhere on your website, but make sure you block it from robots and crawling.

Here’s a quick and easy page that you can use, just make sure to update your Google Analytics account number and make sure the cookie settings are the same as currently on your site. For those unaware, this is the part that follows your account number in the GA tracking snippet. For us, that just says “auto,” but you may have your site name in there.

This page requires a button click, though you can make this page automatic if you’re building this into a standardized process. We also ask for the employee’s name, so we can check later to see who all participated in opting out.


<!DOCTYPE html>
<html lang="en">
    <title>Opt out of our Google Analytics Tracking</title>
    <script type="text/javascript">
        (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
        ga('create', 'UA-12345-1', 'auto');
        body {
            font-size: 18px;text-align: center;font-family: verdana;
    <div style="-webkit-border-top-left-radius: 15px;-webkit-border-top-right-radius: 15px;-moz-border-radius-topleft: 15px;-moz-border-radius-topright: 15px;border-top-left-radius: 15px;border-top-right-radius: 15px;width:400px;height:90px;margin:auto;background-color:#f00;box-shadow: 5px 5px 2px #ccc;">
        <span style="font-family: Helvetica, Arial,  sans-serif;font-weight: bold;font-size: 48px;color: #fff;margin-top:10px;">Hello</span>
        <span style="font-family: Helvetica, Arial,  sans-serif;font-size: 26px;color: #fff;">my name is</span>
    <div style="width:400px;height:115px;margin:auto;box-shadow: 5px 5px 2px #ccc;background-color:#fff;font-family: Comic Sans, Comic Sans MS, cursive;font-size: 60px;color: #000;padding-top:20px;">
    <div style="width:400px;height:25px;-webkit-border-bottom-right-radius: 15px;-webkit-border-bottom-left-radius: 15px;-moz-border-radius-bottomright: 15px;-moz-border-radius-bottomleft: 15px;border-bottom-right-radius: 15px;border-bottom-left-radius: 15px;margin:auto;background-color:#f00;box-shadow: 5px 5px 2px #ccc;"></div>
    <form action="#" onsubmit="ga('send', 'pageview',{'dimension1': 'employee-' + getElementById('employeename').value});alert('You are now opted out! Thanks for your help, '+getElementById('employeename').value+'!');return false;">
            <label for="employeename">My Real Name Is:</label>
            <input type="text" name="employeename" value="Super Hero" id="employeename">
            <input style="height: 45px;width: 100px;border-radius: 10px;font-weight: bold;margin-left:10px;" type="" value="OPT OUT &rarr;">

Creating a Opt Out Bookmarklet

A page can be good, but how about a simple button? I’m a big fan of bookmarklets for desktop browsers because they are browser agnostic and easy to use.

For those unfamiliar, a bookmarklet is a tiny bit of JavaScript that you store as a “Bookmark” or “Favorite.” When you’re on a particular page and click the button, it executes that JavaScript on that particular page. The easiest way to do this is to click and drag a onto your Bookmarks Toolbar, or if that doesn’t work, copy and paste the link and use that for your bookmark link.

In this example, we’ll use a small script to say, 1) Check to see if I’m on the right domain and if so, 2) set a custom dimension and 3) send a Universal Analytics pageview to Google Analytics.

Fill in the following two boxes then hit Generate to create a custom bookmarklet for your site!

Insert your top-level website domain here:
Insert your custom dimension slot:

GA Opt Out

Drag and drop this link onto your bookmark toolbar!

Opt Out Extensions

There are also some Chrome Extensions out there that will do something similar that my bookmarklet – check out Simo Ahava’s Internalize extension. These may be a good fit for your company, but keep in mind that if your employees have the freedom to choose their own browsers, then this may not work for everyone.

There’s also the Google Analytics Opt-Out Extension, but this will stop Google Analytics for all web browsing, not just your own website.

Begging and Groveling

For all of the voluntary options listed, visiting a particular page or clicking a button, you should explore all automated options available to you. The best options are invisible to your users or as painless as possible.

Can you do any of the following?

  • Set a homepage at the enterprise level for all your employees?
  • Open a particular browser window on employees’ computers on a set schedule?
  • Add opting out to standard updates?

When all else fails, you have to just start nagging. Explain to your employees why it’s so important to remove their data from your Google Analytics and remind them every month to participate in opting out on every browser and every device.

Incentivize participation and use a custom report to check to see who actually opted out. Again, you’ll never to be able to account for 100% of internal traffic, but these approaches will begin to improve your data quality!

Consider Google Tag Manager

For the bold – consider doing almost all of the previous methods from within Google Tag Manager. Working with your development team, you should be able to use IP Address filtering as well as setting and retrieving cookies to create Trigger Exceptions from within Google Tag Manager. In addition to setting a custom dimension, set and store a cookie that sticks with a user for as long as possible.

These tactics can be used to block tags like Google Analytics, third-party marketing tags, surveys, or advertisements from firing for the wrong people. Read more about using Google Tag Manager to exclude types of traffic.

The post Identifying and Filtering Internal Traffic from Google Analytics appeared first on LunaMetrics.


You might also like More from author

Leave A Reply

Your email address will not be published.