Most of us use Google Analytics (GA) to track the performance of our website since it’s free and easy to use.
However, high volume of the traffic might come from our own visits while working on the website. We definitely do not want this to influence the number in the GA report.
Two Approaches we commonly used to exclude internal traffic:
1. Filter based on IP address
2. Filter based on cookie on special page / WordPress access
IP address filtering is recommended by GA. It’s easy. All you need to do is just to find out your IP address and filter it out. It only works if you have a static IP or a range of IP that you want to filter. As I always travel and move around, I found this method is not as effective.
Therefore, I also added a filter based on cookie. This method involves placing a line of codes on a special page or WordPress function.php to set a cookie when the page is accessed. The existence of this cookie sets a custom dimension and sends the data along with standard page view to GA. This method does not require static IP and can be used to filter only specific user (or computer) instead of everyone on the IP.
Filter based on IP address, follow the steps below
1. Search your public IP address on Google
2. Create a new view on Google Analytics
3. Create a new filter on Google Analytics and enter your IP address
Filter based on cookies, follow the steps below
1. Create a new view on Google Analytics if you haven’t done so
2. Create a new custom dimension
3. Create a new filter for the custom dimension
4. Create a special page and add the set cookie function
5. Add the codes that set the dimension when the cookie exist directly above ga(‘send’, ‘pageview’);.
If you are using WordPress and want to exclude your visits when you are logged in
– Add the set cookie function in the functions.php file
Codes used in this tutorial
1. Set cookie on the special page
2. Set cookie in the functions.php
3. Set dimension when cookie exists (put this directly above ga(‘send’, ‘pageview’);