Filter Internal Visits from Google Universal Analytics


Filtering your own traffic from Google Universal Analytics is done slightly differently to the older version.  Back in 2012 I wrote a short guide on How to Filter Your Own Visits from Google Analytics and thought I’d produce an updated one for Universal Analytics.

The principle is similar.  We still create a subfolder to trigger the ‘ignore me’ cookie setting and then we use a Custom Dimension to ensure the rest of the visit/session is ignored.

As stated before, this method is an alternative to filtering out traffic based on IP information

We need to do the following:

  1. Create a subfolder on your site that you will use to set the masking cookie.
  2. Create a Custom Dimension.
  3. Configure Google Analytics to filter the subfolder you are using.
  4. Configure Google Analytics to filter both the Custom Dimension value
  5. Create a default web document (probably index.html) inside this folder and configure it to set the masking cookie and then redirect back to the site root.

1) Create the Subfolder

This is the URL you will use to set the cookie and exclude your resulting traffic from the Analytics results.

Something like would work well.

2) Set a Custom Dimension within Analytics

From within Analytics, go to the Admin view and under Property select custom definitions.

Click + New Custom Dimension

Enter HideVisit in the name field

Set the scope to User and click Create

(This scope means that unless browser history / cookies are cleared out, your sessions will continue to be masked.  If you want a little more control, set this to session which will only apply to that visit).

This basically tells Analytics to listen for the setting of this custom dimension (think of it like a variable).

3) Create Filter to Hide the initial visit

We need two filters.  One to hide the initial visit to the /mask folder that sets the cookie and then one for the rest of the scope (Hit / Session / User).

Goto Admin and then under view click Filters 

Click + New Filter

Set the filter as follows:

Name: Hide Folder
Filter Type: Predefined Filter
exclude > traffic to the subdirectories > That are equal to
Subdirectory: /hideme/
Case Sensitive: No

Click Save

4) Create Filter to set the Cookie to Ignore the Session

Click + New Filter

Set the filter as follows:

Name: Hide My Visit
Filter Type: Custom Filter
Filter Field: HideVisit (this is the name of your Custom Dimension created in step 1 above)
Filter Pattern: hidden
Case Sensitive: No

Click Save

Everything is now in place from an Analytics point of view, now we have to create the page that will do the work.

5) Create Default Web Document

By taking advantage of the default web document (usually index.html) we can use as the URL that triggers the filter.

Create the following index.html within your /hideme folder (double click to select all for copy/paste):

[sourcecode language=”plain”]
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),

ga(‘create’,’UA-99999999-99′, ‘’);
ga(‘set’, ‘dimension1’, ‘hidden’);
<title>Hide from Universal Analytics</title>
<meta name="robots" content="noindex">
Visit has been excluded from Universal Analytics….

The index.html file uses a simple layout that incorporates your current Analytics Tracking code.  Ensure you change UA-99999999-99 and to your settings.

The script sets the Custom Dimension and then uses a Meta Redirect to go back to the root of your site.

Once this is complete, you can test the script by pointing your browser at and ensure that you get the re-direct.

And that’s it you’re all done.

An important thing to note here is that you cannot rely on the Real Time Analytics view for testing.  This doesn’t seem to take note of the filters properly so don’t rely on this for confirmation.  You will see after a couple of days that your own visits to your website will now be excluded.

I hope you find this article useful and please feel free to post any questions in the comments.


  1. I’ve tried this method to the letter but didn’t work. It still detects my visits.
    Is it still current? Is there a way to check if it has correctly implented inside analytics?

    Thank you so much for your effort in such detailed tutorial, though! 🙂

    1. Hey Sergio and welcome to the site.

      Yeah the information is still current, I’m using the same method myself. How are you testing to see if it’s working? Hopefully not with the Real Time view as that is confirmed not to use the filters.

        1. Hey Sergio. Hopefully this will be the issue. Also worth making sure you’ve updated the other placeholders like the Analytics tracking ID etc.

          Something I overlooked to begin with was ensuring that the initial visit was filtered out too, otherwise when you first get to the site and before the value is set – your visit will be recorded.

          1. It worked!! Great tutorial!!
            Just to complete a little bit the tutorial. To create a filter only to view the internal visits with the include filter with the new dimension, what would be the right way?

      1. Hi Patrizio, glad you found what you were looking for. Even without the noindex or a robots.txt entry, unless you specifically link to this page from somewhere or manually submit it to the search engines – it’s very unlikely they would find it.

  2. At last, a convenient solution for the new Universal Analytics, and all well explained. – Just waiting a couple of days to see it it works !
    Thanks for a great post.

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.