Tricks For Advanced IP Filtering With Google Analytics

Tricks For Advanced IP Filtering With Google Analytics

Clean data is what we analytics guys strive for.  In order to keep Google Analytics reporting as clean as possible it is vitally important to filter out visitor data that is not true customer traffic. If you don't, visitor patterning is severely affected, generally with poorer quality metrics and higher CPA/CPC data.

The types of visit we need to exclude from profiles include site designers, administrators, and regular staff visitors from various locations. The way to do this is to setup IP address filters for visits from these locations. To undertand the basics on IP filtering  I recommend you visit our previous post Setting Up Filters and Profiles in Google Analytics.

In this article I wanted to explain the following:

  • Help you understand more complex IP filtering for those that need to block ranges of IP addresses
  • I also describe how to setup a PHP test page and Google Analytics profile that will help report on any IP address you might have missed so that you can perfect the filter.

Filtering Dynamic IP Address Ranges

Filtering basic IP address is described in the previous article.  If you have multiple locations, however, or if your ISP regularly changes your IP address filters things can be a little more tricky. For a dynamic address you need to contact your ISP to get the range of addresses they use for your account. Then use Google’s range expression creator tool to create the expression you need to filter for. Example: For a range of 192.168.1.1-25 and single static address of 10.0.0.1 the filter would be:

^192\.168\.1\.([1-9]|1[0-9]|2[0-5])$|10\.0\.0\.1

Here is more information on how to create filter expressions.

Testing the Filter Works in Analytics

In order to see whether your filter is correct for your staff locations, we can send the IP address of visits to an an analytics profile. Here’s how: Please note: This should be used only for  a non-public profile and recording your staff visits, since recording external visitors personal information is against Google's terms of service.

1) Create a new profile with a separate tracking ID in analytics just to carry out this test. Don’t add the filter yet and just to be clear, leave your live profiles alone until the very end!

2) Create a test.php page on your live site, out of normal public reach. On this page include the analytics code for the test profile but add the line in red. Place it below the call to the tracker. This pulls the IP address of the visitor into the setVar variable so it can be viewed in analytics.

<script type="text/javascript"> var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E")); </script> <script type="text/javascript"> try { var pageTracker = _gat._getTracker("UA-xxxxxxx-x"); pageTracker._trackPageview(); pageTracker._setVar("<?php echo $_SERVER['REMOTE_ADDR']; ?>"); } catch(err) {}</script>

You can also echo the IP address to the page, if you wish, using something similar to the below:

<h1>Thank You!</h1><br /><strong>Your IP Address is <?php echo $_SERVER['REMOTE_ADDR']; ?></strong></br>Your address will be registered in analytics if we have not blocked your visit correctly!

clip_image0013) Now test the page by visiting the test.php page and wait for analytics to report the visit with the IP address.Look in Visits – User Defined. This generally takes a couple of hours.

4) Once you have confirmed that the test.php page is sending missed IP addresses into the user defined field then apply your filter to the NEW profile.

5) Send an e-mail to all locations asking for people to visit the test.php page. Make it clear that they should only visit from the locations you wish to filter for.

6) Wait for the result to come in and then check the profile report. You can see exactly which addresses your filter missed.

7) Modify your filter and and retest.

8. Finally, apply the complete filter to your live profiles safe in the knowledge that your visitor data is not being tainted! This post should help identify any errors to your IP Filters and assist with providing as clean a data set as possible to make evaluations of web site performance.

Final note: It is useful to save the test page to retest periodically to catch any dynamic IP changes that you might not have captured.

It's a competitive market. Contact us to learn how you can stand out from the crowd.

Read Similar Blogs

Post a Comment

2 Comments

  • avatar

    Thanks for every other informative web site. Where else may just I am getting that type of info written in such an ideal manner?
    I’ve a undertaking that I’m just now running on, and I’ve been on the look out for such
    information.

  • avatar
    candy crush cheats level 102 

    on 

    Just wish to say your article is as astonishing. Thee clearness in your put up
    is just excellent and that i can suppose youu are an expert on this subject.
    Well together with your permission leet me to seize your RSS feed to stay up to date with drawing close post.
    Thanks 1,000,000 and please caqrry on the gratifying work.

Ready To Rule The First Page of Google?

Contact us for an exclusive 20-minute assessment & strategy discussion. Fill out the form, and we will get back to you right away!

What Our Clients Have To Say

L
Luciano Zeppieri
S
Sharon Tierney
S
Sheena Owen
A
Andrea Bodi - Lab Works
D
Dr. Philip Solomon MD
Follow On Instagram
@techwyse