How to stop Google Analytics from recording my own page views – excluding visits on dynamic IP too

Google analytics, undoubtedly one of the main tool used by webmasters and website owners to track their visitors statistics on http://nabtron.com/how-to-stop-google-analytics-from-recording-my-own-page-views-excluding-visits-on-dynamic-ip-too/6495/blogs and websites. It’s mostly accurate, but to make it more accurate, you might want to exclude your own visits to your website (or of team members).

In this tutorial, you will learn how to setup filters in google analytics to exclude logging your own visits to your blog or websites, thus avoiding google analytics code from recording your own page views to your stats.

How to setup filters in Google Analytics to exclude your own page views

1. Creating a Custom html file

We need to create a custom file before we proceed to Google Analytics part. This custom file has to be a custom html file to be accessed on the computer which you want to be excluded from google analytics by using filter.

Name the file exclude.html (or anything else you want). Add this to the body opening tag:

<body onLoad="javascript:__utmSetVar('no_report')">

You have to run open this page once on the browsers / computers that you want to be excluded from google analytics stats. This code will create a cookies for that browser with  “no_report” in it.

2. Create a Custom Filter in Google Analytics

Login to Google Analytics account by going to Google.com/analytics

Once logged in and on the dashboard for your google analytics account, goto bottom of the analytics home page and find Filter Manager  Click it to goto Filters manager page. This page lists filters that you’ve created for sites in your google analytics account.

Create a new filter by clicking Add filter

Give name to the filter (I named it Exclude My Visits)

From the options for Predefined or Custom filter, select the radio button for Custom Filter

From next row chose: Exclude 

Chose Filter Field to be user defined

Enter Filter Pattern to be no_report

Chose Case Sensitive to be No

Select the sites you want this filter to be applied to (I selected all of them) and Save Changes

Note: it’s recommended to change “no_report” to any custom name both in custom filter and body tag so that it don’t interfere with any other user coming to your site with this cookie active in his browser.

3. Test your settings

To test and confirm your settings, make a new page (e.g: tester.html other than exclude.htm) on your website and add normal google analytics code to it. Now open it couple of times before running that exclude.html file (so that the hits get logged)

Check the stats after 24 hour and confirm that the hits are being recorded in Google Analytics

Now run the file exclude.html to apply the filter cookie so that google analytics excludes it now. Run the tester.html few times and check the stats again after 24 hour and it shouldn’t show it (if you used the same computer and browser without cleaning the cache ofcourse)

Now google analytics won’t record page views from your own computer even if you’re visiting your website or blog over a dynamic ip address and not just static.

Feel free to ask any questions if you have.

2 comments on “How to stop Google Analytics from recording my own page views – excluding visits on dynamic IP too

  1. Hi,

    I have done d same thing. Created an extra.htm page with the following code:

    var _gaq = _gaq || [];
    _gaq.push([‘_setAccount’, ‘UA-XXXXXXXX-X’]);
    _gaq.push([‘_setVar’,’cookie_excludeGA_XXXXXXX’]);
    _gaq.push([‘_trackPageview’]);

    (function() {
    var ga = document.createElement(‘script’); ga.type = ‘text/javascript’; ga.async = true;
    ga.src = (‘https:’ == document.location.protocol ? ‘https://ssl’ : ‘http://www’) + ‘.google-analytics.com/ga.js’;
    var s = document.getElementsByTagName(‘script’)[0]; s.parentNode.insertBefore(ga, s);
    })();

    Then I created the exclude filter in GA. But now I can see the excluded visits in User Defined report of GA. Not only that I have total 1152 visits to the website. The user defined report shows 1150 visits (not set) and 2 visits under the cookie name that I created. This clearly means that GA is not excluding my visits. Can you please guide what is wrong with it?

    Thanks.

Leave a Reply

Your email address will not be published.