Identifying and Filtering Internal Traffic from Google Analytics

Identifying and Filtering Internal Traffic from Google Analytics

/

blog-internal-traffic

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 192.168.1.1 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:

blog-filter-ip

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:

blog-optout-iprange

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:

blog-filter-ip-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.

blog-custom-dim-visitor-type1

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.

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.

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.

blog-opt-out-page

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 link 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:

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.

About

Jon Meck is our Technical Marketing Manager, promoting our services and trainings to the world. He has a jack-of-all-trades background, working for companies large and small in social media, website design and maintenance, and analytics. He is an Excel enthusiast, he loves efficiency, and he is strong proponent of the “Work Smarter, Not Harder” mantra. Jon is also the author of two number puzzle books.

  • Jaspert Beenen

    Finally I found a comprehensive page for universal analytics. Tnx very much for this post!! With these many options I’ll certainly make it work

    • Jaspert Beenen

      Hi John,

      I ran into some complications. I set up the custom dimension as you described, I’l also manage to put the code snippet on that single page that everyone must visit + the manual opt out page. But what I don’t understand is this: #1 Howcome when I make a segment and want to exclude all traffic with custom dimension Visitor type–>employee the calculation from analytics is 100% of the traffic? And #2 How do I use this custom dimension in a Filter .. I don’t see it available as in a Segment

      • http://www.lunametrics.com Jon Meck

        Hi Jaspert,

        There may be a few issues at play here.

        1) If you’re seeing 100% traffic, you may have it set up incorrectly on your site. Remember it will take time for the traffic to collect.

        2) I think you may be confusing Advanced Segments and View Filters. Ideally, we would create a new Filter, which can be found under View Settings on the Admin tab. Then we can do a custom filter to Exclude traffic that matches your conditions. I would recommend creating a Test View first to make sure that this is working properly.

        Hope this helps!
        -Jon

        • Jaspert

          Hi John,

          1) I’ve only set up the dimension as described, then used the dimension in a segment. I’ll talk with Eric to see if Lunametrics can assist and see what’s wrong in the setup

          2) Nope I know the difference, this is why I was first testing with a segment. If it actually works, I don’t want the traffic included so I used the filter.

          Tnx for replying! 🙂

          • http://www.lunametrics.com Jon Meck

            Hi Jaspert –

            1) I created a segment exactly the same as you and can see that it’s filtering out some of my employees. I would check back after some time and see if this number goes down.

            2) Makes sense – sorry for the assumption. If you weren’t seeing the custom dimension available to use in your filters, then you may have been trying to create the Filter under the Account instead of the View. Because custom dimensions are different for each property, you need to start under the View settings, and create a new Filter that way.

  • pinpin

    Hello Jon, regarding the bookmarklet opt out.. what should i input to the custom dimension field ? how the field work ? sorry for the silly question.. Thanks in advance

  • Sasha Poda

    I have a subdomain with its own property. How do I implement “same domain common pages” method using one homepage? Do I need to add line like ga(‘create’, ‘UA-123456-2’, ‘auto’);?

    • http://www.lunametrics.com Jon Meck

      Sure – you can send multiple pageviews on the same page to two different properties, especially since these will just get filtered out. You’ll need to be careful though, working with multiple trackers can get a little tricky. You might want to use a separate named tracker.

      ga(‘create’, ‘UA-123456-2’, ‘auto’, ‘subGA’);
      ga(‘subGA.send’, ‘pageview’,{‘dimension1′:’employee’});

      The more important issue will be what your cookie settings are like on the subdomain. If you have ‘auto’ on your subdomain, then this will work, because it will look for a GA cookie at the top level domain. If you have the subdomain listed like “sub.example.com”, then you won’t be able to get this to work unless you have code on a page on that subdomain.

  • http://about.me/zacchaeus Zacchaeus Nifong

    Hey Jon, thanks for such an awesome article. I’ve got a quick question for you, so please forgive me for being frank; I’m trying to use Advanced Segmentation to filter our company IP address, but I don’t know the dimension to use. Should I be using Conditions > Filter (Users) Exclude > Source > matches regex > ^207.190.88.38$ ? I can’t seem to find the answer online if you can retroactively filter IPs using Advanced Google Analytics Segmentation. Thanks brother and I appreciate your hard work on this.

    • http://www.lunametrics.com Jon Meck

      Hi Zacchaeus,

      Unfortunately, it’s not possible. The IP Address dimension is only available during the processing stage, so you can’t pull it out with Advanced Segments or any specific dimension in the reports.

      You could try to create segments for users that at any point hit an internal only page, but you can really only use some sort of activity on your site.

      Source/Medium will tell you how someone got to your site. You could look there to see if any of the source/mediums would somehow identify a chunk of traffic as being internal, for instance if someone arrives from your dev site to your live site, you could logically conclude that that person is internal (or how else would they find your dev site…)

      Hope this helps, sorry it’s not the answer you’re looking for!
      -Jon

      • http://about.me/zacchaeus Zacchaeus Nifong

        Excellent information, and that’s exactly the answer I was looking for. I’ve added Lunametrics to my Feedly Reader so I’ll be watching your brand. Thanks so much for the quick reply. I’m glad to have found you.

  • Tom Zhang

    192.168.1.1 – that’s local IP, shouldn’t it be a global IP?

    • http://www.lunametrics.com Jon Meck

      Tom – you’re correct. I was just using an example, though looking back – it would have been better to use something that looked like a public IP address!

      • Victoria

        Hi Jon. Thanks for a great article.

        Is it problematic using a local IP? I want to filter 31 different IP-adr. for a client. They´re all defined with a 10.14.XXX.0 (which is a local IP, right?). Is there some sort of translation in GA that makes this challenging? As is, I want to create two new views; 1) excludes all the IP-adr and 2) include only the IP-adr.

        My current filter looks like this: 10.14.([2-7]|1(01|1[1-7]|2(3|5|6)|44|5(2|4|5))|6[3-5]|7([2-6]|9)|9(0|1|9)).0

        At the moment, the separate views are not differentiation in traffic, so I fear that something is off. I´m not able to test, as I dont´t have access to log on from the IP-adr.

        • http://www.lunametrics.com Jon Meck

          You cannot use a local IP address, you must use the public facing IP address. Think of it like your physical address to your office. The best way to get this address is to just Google it from within your office: http://lmgtfy.com/?q=what+is+my+ip

          This is the IP address that Google will use for filtering.

  • Nick Harris

    Great guide on setting up custom dimensions and methods of sending that data in, but I’m stuck on how to actually apply the filter. I’ve got “ga(“send”, “pageview”, {dimension1: “employee”})” firing when logged in employees are on my website, but when I go to select the “Filter Field” to exclude, I’m not sure which one to select or how to configure… Any insights here?

  • May Elia

    I have scheduled an email as monthly report with browsers used to access web
    pages. But in the generated report, I don’t see any browser shown? Please advise!

  • http://navianalyzez.blogspot.com/ Navaneeth Murali

    Hi. I have website testers and sales rep and all other employees. Currently we have excluded all the IP address in our building hence our sales rep IPs are also blocked but we would like to see the ecommerce tracking for the sales rep. Hence we have included the sales rep IPs in the GA filter and moved it up the rank to #1, But their IP is still in the exclude filter which is #4 in the filter rank. So my question is will GA include my sales rep IPs or exclude them ?
    We have over 1000 employees in the building and have 12 sales rep. So what solution would you guys suggest inorder to accomplish this ?

    • http://www.lunametrics.com Jon Meck

      Hi Navaneeth,

      The filters will be applied in the order that they are listed. If you start with a big pool of data, and then use an Include filter to only include traffic from a few IP addresses, then you’ve effectively filtered out a huge majority of your traffic. Then later, if you filter our those IP addresses, then you’re left with nothing.

      You should not combine the include and exclude filters like this. Your best bet would be to update the Exclude filter to not Exclude your sales reps. If this is not possible, then you could look into creating a separate View for tracking their efforts.

      When you use an Include filter, think of it as an “Include Only,” which means it will filter out any traffic that does not match.

      Hope this helps!
      -Jon

  • Michael

    Hi Jon,

    thank you for the interesting article. I manage several client accounts and had to create the filters so often that I created a tool for it. It’s 100% free and open source, so there’s no commercial interests behind it. It basically creates an exclusion filter for the IP you visit it with. It’s not as involved (or powerful) as some of the techniques you describe, but on the other hand it works at the click of a button. Maybe you’ll find it useful too. It can be found at http://www.excludemyip.com.

    Thanks again,
    Michael

  • Drew

    Hi Jon!

    I am following your “Creating a Opt Out Page” method, but I ran into an issue with reporting!

    I created GA forum thread on the topic, which can be found here: https://www.en.advertisercommunity.com/t5/Code-Implementation/Custom-Dimension-Values-Missing-From-Custom-Report/td-p/531144

    Maybe you would be willing to take a glance and comment either here and/or over on the thread?

    I would truly appreciate your thoughts!

    Thanks, 🙂

    Drew

    • http://www.lunametrics.com Jon Meck

      Hi Drew –

      Everything looks good with the custom report. Remember, the data may take awhile to show up, though it looks like you’re running a report for yesterday, so not sure how long ago you sent it.

      Confirm that you’re sending the right value to the right dimension. Remember each dimension has an index number, and right now your code is sending it to index #1. Make sure that it’s set to a User level dimension.

      You can use the GA Debugger to see that it’s being sent to GA properly. See this post for more details… http://www.lunametrics.com/blog/2016/03/07/google-analytics-and-google-tag-manager-debugging-tools/

      If it’s being sent correctly, make sure you didn’t Filter it out. Remember if you’re excluding Employee traffic, you should have an Unfiltered View set up so you can see everything without filters. So check there to see if you see anything.

      Lastly, the chart at the top of the custom report is showing you All Sessions to the site, not for this specific report, unfortunately.

      Hope this helps!

      -Jon

      • Drew

        Woo thanks! I think It may have been the GA opt out browser extension blocking things. I got some data in from another test done today. Thanks again. 🙂

  • Lindsay

    Hi Jon, If I want to exclude multiple IP addresses, would I select custom report? Is this the correct way to input it? 169.242.236.243I199.28.129.73I161.253.151.234

    • http://www.lunametrics.com Jon Meck

      Hi Lindsay –

      You would not be using a report for this, you would need to be using something called “Filters.” You find them at on the Admin screen, under the View column. In your case, you could either add a Custom Filter, that matches on IP Address, OR you can just simply create 3 of the predefined IP filters.

      Hope this helps!
      -Jon

  • gravitysystems

    I really like you work. You have done a great job here. I’m glad that someone has dared to show the true picture of life rather than sharing abstract ideas.

  • Christophe Milon

    Hi Jon,

    I have trouble to isolate employees in my company as we haven’t a static IP.

    We use a proxy called Zscaler inc.

    When I look in the domain section in google analytics, I can see traffic coming from Zscaler, I want to use it as the main filter because every employes in my compagny come thought this proxy.

    The problem is that Zscaler is used by other compagny, including some of our customers (BtoB), I’m looking for others filter to use :
    -Browser : Internet explorer 11
    -Screen resolution

    Those are usefull but not perfect as lot of compagny use IE in our sector and we have a ton of different screen resolution in our différents offices.

    For me, the best filter would be the computer as we use only 2 or 3 different model.
    My problem is that I can’t find this option for desktop in GA, I found it easily for mobile btw.

    It’s possible to track the computer model on GA ?

    Thanks a lot for your article 🙂

    Christophe

    • http://www.lunametrics.com Jon Meck

      Hi Christophe, unfortunately, no. Computer model is not a dimension that is stored in Google Analytics. It doesn’t sound like there would be an easy, out of the box solution for you, so I would recommend some of the tips above about creating an internal page or an opt-out page. If possible, you can set these pages as your homepage for everyone in the office or find a way to make it easy for people to find this page and opt out.

      Hope this helps!
      -Jon

  • Rodrigo Catoquini

    Hi Jon,

    Thanks for the information

    I’m having troubles with the IP filter. I want just to filter the IP of my personal computer, but when I set up it the filter blocks all the traffic to my site…

    Do you know what causes this type of problem? I’m doing as your explanation.

    Thanks!

    • http://www.lunametrics.com Jon Meck

      I’m guessing you have some sort of mistake with your IP Address filter. You may be using an incorrect regular expression, or filling in the fields incorrectly.

      Can you share a screenshot or an example of how you tried to set up the filter?

      Thanks,
      -Jon

  • Stephen

    The weightiest users of a site tent to be the individuals from within the group. So it really makes sense to eliminate this organization from your Google Analytic traffic or else your visitor figures will be inflated artificially by internal use.

  • Heather Salovin

    Hi John – I am using a filter on a view to exclude traffic from our dev team using the hostname filter and filter pattern ^dev.examplesite.com$|^new.examplesite.com$ and when I run the “verify this filter” it seems to be working however the data for my goals is still skewed. Know how to fix this? Thanks!

    • http://www.lunametrics.com Jon Meck

      Hi Heather – keep in mind that filtering out traffic will only work from the time you set up the filter going forward. You can never go back and correct data, once it’s recorded in Google Analytics, it’s permanent. Does that answer your question?

      -Jon

Contact Us.

LunaMetrics

24 S. 18th Street, Suite 100,
Pittsburgh, PA 15203

Follow Us

1.877.220.LUNA

1.412.381.5500

getinfo@lunametrics.com

Questions?
We'll get back to you
in ONE business day.