In this short article we will cover – How to exclude internal traffic from your Google analytics reporting which is generated on your website during development, editing and QA/testing of the website.
This traffic leaves you with a lot for bogus insights and data and overall hides the actual results your website is seeing from its visitors.
As those insights are important for you or any website owner.
Google analytics is a great platform that can help you to get to know your audience and improve your products and services if used correctly.
Without further ado lets look into the most basic solutions you can implement to combat this issue.
Adding filters in Google Analytics
Open Google Analytics Account
Admin Settings (bottom left corner button)
Click – All Filters

Add new Filter using the + Add filter button
Filter name: Give it a meaning full name.

Add Logic to the filter for excluding internal traffic from tracking/reporting.
Filter Type: Predefined (custom can be used but not necessarily required here)
Filter logic is as follows:
Exclude + traffic from the IP Addresses + that are equal to
IP Address: provide the IP addresses you would like to exclude as seen in the image example below.

Once, implemented you will be able to see how many times your filter fired or if it is working correctly by checking the views against your filter like in example below:

Google’s documentation on this: here
Wrapping your Google Analytics code in a container
This prevents analytics to fire when certain conditions are met, like: ip address, location or any condition you fancy.
<script type="text/javascript">
if (document.location.hostname.search("myproductiondomainname.com") !== -1) {
//google analytics code goes here
}
</script>