To my knowledge, there are three methods to hide self-visits from google analytics.
1. Google Analytics, Filter IP Address
In this method, we will add a filter to the google analytics dashboard. We use the IP address to filter out the traffic. For this purpose, follow these steps.
Step 1: Open Google Analytics and go to the admin menu at the left bottom of the screen.
Step 2: If you are using Universal Analytics View, then there will be three views, i.e. Account, Property, and View. The first and last view has All Filters options, navigate to any of these.
Step 3: Open the All Filters menu and click the Add Filter button, this will open a new form.
Step 4: Fill out the form fields
- Filter Name: Set desired name of the filter, e.g. exclude traffic.
- Filter Type: Select predefined and choose the options as below image.

- IP Address: Add your IP address in the input field provided to you by your network provider.
- Apply Filters To View: Select the view from the list, which you want to exclude
- Click Save
Congrats, you have added an IP filter.
2. Google Chrome Extension
This method is really simple and easy to configure. Just add this chrome extension and you are all set up. This extension will block google analytics to track your visits.
3. PHP Conditional Statement
This is a really simple method and I myself use it on my website TutsInsider. You have to just follow these steps to get the job done.
Step 1: Go to your theme folder and open the file which contains the Google Analytics tag. We mostly add this code in header.php in WordPress.
Step 2: Scroll to the code line where you have entered the Google analytics script.
Step 3: Wrap this script with the following if statement
.
if ( ! is_user_logged_in() ) {
// Google Analytics Script Goes here
}
You are fine now, as long as you are logged in to WordPress, the page visits won't load the google analytics script. Hence, if the Analytics script is not loaded, Google won't be able to know if someone visited the site.