I know, you have a question in your mind that – Why do we need to exclude our own IP address in google analytics account? Let’s say you have a staff of 100-200 people who are visiting the website on a daily basis. In this case it appears that their traffic also gets counted in the account and it results in huge traffic. This in-house traffic is of no use to track in the account for analysis. So, in order to filter our own traffic/visits in the account we need to exclude our own IP address. If you want you can include your own IP address traffic too in the account by creating an IP filter.
Now, no need to worry about that – we have created a greasemonkey script which is compatible to mozilla firefox browser. Run the script and find the IP address number of your own and then you can decide whether to exclude or include them in analytics profile depending on your requirements.
But, what is greasemonkey script?
It is just a chunk of Javascript code, with some additional information that tells Greasemonkey where and when it should be run. Each user script can target a specific page, a specific site, or a group of sites.
If you want to start writing user scripts, you first need to install the Greasemonkey browser extension, version 0.3 or later
To install the greasemonkey – visit the greasemonkey home page – http://greasemonkey.mozdev.org/
How to Install a User Script
Download – Javascript
Click on Install Button
After installation of the greasemonkey script in your firefox browser, then open your google analytics account and click on Filter Manager > Add Filter > Create Filter.
Then type filter name and select Predefined filter option and then filter type exclude or include – traffic from the IP addresses – and the condition is – that are equal to. Now, fill the IP address number in the four boxes.
As soon as you run the script, the IP address number will fetch in the account and then you have to copy/paste the number in their respective boxes in IP Address column. (Kindly refer below screenshot for more clear picture.)
NOTE: As for now the greasemonkey script is compatible only for Mozilla Firefox browser.
Greasemonkey Script
<script language=”javascript”>
// ==UserScript==
// @name MY IP Script Name
// @namespace traffic from my ip address Script Namespace
// @description Google Analytics IP Filter Script Description
// @include https://www.google.com/analytics/settings/add_profile_filter* Path where this script will work
// @include https://www.google.com/analytics/settings/add_filter* Path where this script will work
// @require http://www.DomainName.com/ip.php
// ==/UserScript==
function getIP() {
return ip;
}
//Functions to split IP address by . (dot)
function test1()
{
var ipa = getIP();
var k = ipa.split(‘.’);
var ip1;
for(var i=0;i<k.length;i++)
{
ip1 = k[0];
}
return ip1;
}
function test2()
{
var ipa = getIP();
var k = ipa.split(‘.’);
var ip1;
for(var i=0;i<k.length;i++)
{
ip1 = k[1];
}
return ip1;
}
function test3()
{
var ipa = getIP();
var k = ipa.split(‘.’);
var ip1;
for(var i=0;i<k.length;i++)
{
ip1 = k[2];
}
return ip1;
}
function test4()
{
var ipa = getIP();
var k = ipa.split(‘.’);
var ip1;
for(var i=0;i<k.length;i++)
{
ip1 = k[3];
}
return ip1;
}
//Disply IP address in Google Analytics Interface
var ln = <b>Your IP Address is : </b><br><input size=”3″ maxlength=”3″ type=”text” value=’+ test1() +’>.<input size=”3″ maxlength=”3″ type=”text” value=’+ test2() +’>.<input size=”3″ maxlength=”3″ type=”text” value=’+ test3() +’>.<input size=”3″ maxlength=”3″ type=”text” value=’+ test4() +’>’
document.getElementById(“ip_address_row”).innerHTML += ln;
</script>
By using the above greasemonkey script, now no need to contact your webmaster or IT department to obtain the IP address of your own to exclude or include them in your google analytics account as per the requirement of your own.
I know you have a question cropping up in your mind; Is it the script works if my IP addresses is static or dynamic. What is static and dynamic ip addresses. To know more about static and dynamic IP addresses check below URL link
http://www.buzzle.com/articles/static-ip-vs-dynamic-ip.html
If your IP addresses is static then no issue just once you have to do the above task and leave it . But if possess dynamic IP addresses then it is recommended not to use the above script due to its ever-changing behavior.
If you find the script helpful, then please share your experience with us.