How to Exclude Internal Visits/Visitors from Google Analytics Reports Using Asynchronous Code

As a Goolge Analytics Consultant, McBuzz helps clients learn about traffic on their website so they can improve visitors’ experience and generate more leads and sales. If you have a website, you should be using Google Analytics to track visitors on your site. But you don’t need to track your own visits to the site, nor do you want to track visits made by other people in your company, or by your clients if you are a webmaster or online marketing consultant.


All these visits are called “internal traffic”: visits made by you or by people who work for the company that owns the website. Data from these visits will skew the results that you really want to see. You want to track visits made by customers and potential customers.

There are a number of ways to exclude internal traffic from Google Analytics reports. Continued…You can exclude visitors based on the IP address of their computer/internet connection. And you can exclude a range of IP addresses so that you can keep visits for a large office of many users out of Analytics reports. This is appropriate if there are many people in an office who all access the company website to do certain tasks.

There are situations where excluding internal traffic using an IP address may not be ideal. If you or people in your office work remotely, then they need to exclude IP addresses at home as well as at work. If you are like me and you work from many different locations, then trying to exclude IP addresses every time you sit down in a coffee shop somewhere can be tedious and time-consuming.

There’s an easier solution: excluding internal traffic using a cookie. When you exclude traffic with a cookie, you can filter out of Analytics reports all the visits you make to a given domain.


You can create the cookie to exclude internal visits using a bookmarklet, but frankly this is about as tedious as using multiple IP addresses. So the way I like to do it is with a simple web page and a little bit of JavaScript.

  1. Create a simple web page
  2. Use the following in the HTML file for the page:
    <script type="text/javascript">
    var _gaq = _gaq || [];
    _gaq.push(['_setAccount', 'UA-xxxxxxx-x']);
    (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
    <meta name="robots" content="noindex">
    <h1>Google Analytics cookie has been created!</h1>
  3. Replace UA-xxxxxxx-x with your Google Analytics account ID
  4. Save the file with whatever name you want. I use the domain name plus “no-report”, for example: yourdomain-no-report.html
  5. Upload the file to the “root” directory of the website, so you can get to the page by going to
  6. Note that this HTML page and the cookie it creates use the asynchronous Google Analytics script. If you are using the old version of the script or you are not sure what you are using, contact me.
  7. Here is the Google Analytics Asynchronous Code Usage Guide.


    Next, create a custom “Exclude” filter in Google Analytics using the Filter Manager.

    1. Login to Google Analytics
    2. Click on the website name in the main dashboard
    3. Now you will see the dashboard for that particular site
    4. Click on the Google Analytics Filter Manager (shown here)
    5. Add a new exclude filter with these settings (shown here) – To see this image at full size, click here. Then right-click on the image and select “View Image”.Filter Settings
      Filter Type: Custom filter > Exclude
      Filter Field: User-Defined
      Filter Pattern: no_report
      Case-sensitive: No
    6. Be sure to select the name of the website under “Available Website Profiles” and click the Add button to add it to the “Selected Website Profiles”
    7. Click Save Changes

    Finally, after you have uploaded your HTML file, you need to go to the address where you can view that page with your web browser. For example:

    Once you see that page, you are done. Just close your browser window or go to any other web page.

    You need to be sure to visit that page with every browser you use to view or work on your site. And everyone one at your company should do the same. So if you use one computer at home and another at work, you need to go to that cookie page with each machine. If you use more than one web browser, you need to go to that page with all of them. If you clear out (delete) your cookies, you’ll need to visit the page again after doing so.

Tracking Visits to the Exclude Filter Page

By including the Google Analytics tracking snippet on the cookie filter page (like this filter page does), you can see who visits the page. This is valuable info if you are a marketing consultant, because you can see if your client has visited the page like you asked them to! And if you have asked more than one person to do so, you know who has and who has not. Note in the real example below that, so far, only one person has visited the page (on two different browsers).

Google Analytics Exclude Filter - Tracking Visits

You can check the Google Analytics Exclude Filter page visitor stats to see if people you asked to visit the filter page have actually done so.

Comments: 23


I hadn’t been using this filter.. just found your site from wordpress tv
now i have added this filter so thanks for the tip!
Cheers Scott

this link doesn’t work Add a new exclude filter with these settings (shown here)

@pascal – Thanks. The “Add a new exclude filter” link is fixed.

Thanks for this post Mark! The steps are easy to follow and it works better than ip filtering when you work on a laptop in multiple locations.

@Seb – Glad to help! Good luck with your mobile apps marketing site.

Currently my domain is being hosted on a temporary sever and I don’t have the pass word to upload the file. I wil be moving to another hosting company within the next 2 months; however I wanted to know what exacly are bounce rate

@yesi – Bounce rate on a website is the percentage of single-page visits as compared to the percentage of visitors that go to more than one page on your site. If your site has 100 visitors in one day, and 50% of those visitors go to only one page on your site before returning to the Google search page or going on to some other website, then your site has an overall bounce rate of 50% (on that day).

Bounce rate for a single web page is the number of visitors that land on that page (called the “entrance page” or “landing page”) – who don’t go to any other pages on your site – divided by the total number of visitors to that page. So if 10 people go to a particular page on your site – directly from a Google search, for example – and 7 of them leave the page without going to another page on your site, that page has a bounce rate of 70%.

High bounce rates are bad, in general, because they mean that people visiting your site are not interested in what you offer. That’s why it’s important to optimize your posts and pages for the right keywords, and to give visitors lots of ways to find related information, using a Related Posts plugin, putting related links in your sidebar, using Tags and Categories on your blog, and putting eye-catching graphics in your sidebars.

There’s a good summary of bounce rate here on the Google Support site.

Hi, Mark,

Very helpful 🙂 Being looking for this solution for a long time, finally!!

BTW, how do i know whether it has filtered my internal visits already?


@Lifen – Try using a Google search with your domain name plus something you can identify that no one else will search like “ three of cups testing”. Click the search listing to go to your site. If the filter is NOT working, you will see this keyword in Google Analytics (Traffic Sources > Search > Organic) within 24 hours. Let me know what you find out. I have had mixed results lately with this cookie-based filter. I have gone back to using IP address filters to be safe in some cases.

Hi, Mark,

Just tested it with your solution, it worked 🙂

Thanks for the advice !


Thanks for your article. Do you know how to filter internal and external visitors so you can compare the two visits? I don’t want to exclude the internal visits from being counted in GA. But, I do want to compare the number of internal vs external visits to pages. Is that possible? I’ve ready a bunch of articles on using filters for excluding internal visits. But haven’t found anything on how to separate the two in a comparison report. I’d like to have a simple report like the Visits that compare with New Visits metric. Thanks.

@aw – The best way to do this is to create new Google Analytics profiles. I wrote a short post about it here: Comparing Internal and External Visitors in Google Analytics

Can you tell me how come my information was prepopulated in the text fields such as my name, email and website. Anyhow I also would like to know how can I use google analytics wtih a website and not a Blog. I know you can use it with Blogs but how would you use it with a Website.



I’ve been using your exclude internal visits/visitors cookie for some time. Am a fan. Have also update these cookies using the GA method you’ve linked to in this article . Just set this up again for this new site

Wondering if you could please assist: I’m trying to figure out exactly how to setup the correct filter type and ‘filter field’ in Google Analytics in order to exclude facebookexternalhit/* as described on this page

(An extract from the page says, “If you use an external analytics system, there are a couple of steps you can take to ensure proper counts for page hits on your domain. First, exclude requests with a user agent matching facebookexternalhit/*. This user agent is used by the Facebook Open Graph tools to retrieve your og meta tags. Second, track clicks from plugins embedded on your site separately from clicks with a referrer. Social Plugins with have a referral URL matching*.”)

Do you have a tutorial on how to go about this? And/or would you mind providing a few simple instructions please?


@JayD – Awesome question. I don’t have a quick answer. Sorry. But I’ll look into it and try to post it here in the next day or so. If you figure it out in the meantime, please let me know. Thanks!

@JayD – Here’s a first stab at a solution. Note first that you should always create an UNFILTERED profile as a backup to any other Google Analytics profile you may be using. You can also create a TEST profile in which you implement any proposed filters so you can see if they work before you apply them to your main profile. Apply the following filter to your TEST profile and compare it to your main profile to see if it excludes the Facebook traffic as desired.

One way to create your filter would be to use Advanced Segments. Follow the instructions in this post:

Your Google Analytics Advanced Segment should look like this [click to view]. If you use Advanced Segments, you don’t need to create a separate profile to see the non-Facebook traffic. (This assumes that the segment works to show you the data you are looking for. The only way to find out is to test it. Seems to me an advantage of using a segment is that you can turn it on or off while viewing the same profile. You don’t have to switch between profiles. And you can more easily compare the two traffic sources.)

Following the same logic, but using Google Analytics Filters, you can create a Custom Filter you can apply to your TEST profile. Your Google Analytics Filter should look like this [click to view]. If this works to exclude the right traffic, you can apply the filter to your main Analytics profile.

Once again, always create a separate profile that has NO FILTERS so that you can look there any time you think you may have filtered out something you did not want to filter out. Once you apply a filter to Google Analytics data, the data will not be collected. You cannot go back and retrieve that data later on.

Hi Mark – thanks heaps for this! Really appreciate the effort you’ve gone to in supplying this information.

Atm looks like the cookie and filter to block internal traffic is working (following the tutorial toward the bottom of this page sub-headed ‘To exclude traffic by Cookie Content’ .

Will setup the Advanced Segment following your instructions now to block the facebook facebookexternalhit/*

Thanks again and will let you know how I get on!

@JayD – Great! Let me know how that works out.

looks like google no longer supports this filtering. the support page that is linked to multiple times in this article & comments no longer mention it.

Mark McLaren

Oct 26, 2012

9:01 PM

@Laura – Here is an easy example of how to use the filter in a web page.

Thanks for the screenshot with filter manager shown – very helpful.

Thanks a lot for this post Mark ! Can you tell me how can i check the IP filtering report ?

Mark McLaren

Jan 28, 2013

11:12 PM

When you create a Google Analytics profile you should also always create another profile called “ UNFILTERED”. As the name suggests, this profile should be left as-is, without any filters. This profile will show all visits, as opposed to the profile that filters out any visits from a particular IP address. You can make sure IP filtering works by using your own IP as a filter, doing a search for a bogus or unique keyword (like “mcbuzz communications online marketing and cool stuff like that”) and then going to your site via the search results page. Check each profile for the visit via that keyword. Does that answer your question? Make sure you are not signed into Google when you do the search, or you won’t be able to see the keyword in Google Analytics. Instead you’ll see (not provided).

You can also compare visits in the two profiles on a specific date.

Leave a Comment