Most of the time, Analytics is used to track how external customers and users interact with your website, since internal traffic patterns are typically different from external traffic patterns. When your reporting views contain hit data from both internal and external users of your website, it might become difficult to determine how your customers are actually interacting with your website.
As an example, let's say you have an ecommerce website. Internal traffic might include stress testing that will send a large number of hits to a particular page on your website. Your reports will show a large number of hits on this page and it will be difficult to discern how many hits came from customers and how many hits came from your stress testing.
Create an IP address filter
If your network is IPv6 compatible and you are sending IPv6 addresses to Analytics, then make sure your filter uses the IPv6 format for those addresses.
If you are sending IPv4 addresses, then make sure your filter uses the IPv4 format for those addresses.
To prevent internal traffic from affecting your data, you can use a filter to filter out traffic by IP address.
You can find the public IP address you are currently using by searching "what is my ip address" on google.com. You can find out what IP addresses and subnets your company uses by asking your network administrator.
To create an IP address filter:
- Follow the instructions to create a new filter for your view.
- Leave the Filter Type as Predefined
.
- From the Select filter type menu, select
.
- From the Select source or destination menu, select traffic from the IP addresses.
- From the Select expression menu, select the appropriate expression.
- Enter the IP address or a regular expression. See the examples below.
If you have multiple IP addresses or subnets to exclude, you can make more than one filter. As with all filters, make sure the conditions you specify don't interfere with or contradict each other.
To exclude a single IP address, such as 192.168.0.1, set up the filter like this:
- Filter name: enter a name
- Filter type:
Predefined
- Select filter type:
Exclude
- Select source or destination:
traffic from the IP addresses
- Select expression:
that are equal to
- IP address: enter a single IP address
For a subnet of IP addresses like 192.168.0.*, set up the filter like this:
- Filter name: enter a name
- Filter type:
Predefined
- Select filter type:
Exclude
- Select source or destination:
traffic from the IP addresses
- Select expression:
that begin with
- IP address: enter the IP address, minus the subnet
IPv6 addresses (which look like 2620:0:10e2:2:c4bc:9fd2:974f:cf19) can be excluded in the same way as standard IPv4 addresses. Here's an example of a subnet exclusion filter in IPv6:
- Filter name: enter a name
- Filter type:
Predefined
- Select filter type:
Exclude
- Select source or destination:
traffic from the IP addresses
- Select expression:
that begin with
- IP address: enter the IPv6 address, minus the subnet
Regular expressions let you create custom IP exclusion filters. For example, here's how to exclude the address 192.100.0.1 and any subnets of 192.168.0:
- Filter name: enter a name
- Filter type:
Custom
- Select filter type:
Exclude
- Filter field:
IP Address
- Filter pattern:
^192\.100\.0\.1$|^192\.168\.0.*$
Make sure the filter works
You can verify most types of filters before you save them (using the Verify this filter feature). Unfortunately, it's not possible to verify an IP address filter in this way. You can, however, use the Google Tag Assistant Chrome browser extension to record a flow on your website that sends hits to your property. The extension has an Analytics report that can show the effects of any filters set for your view.
Use Tag Assistant Recordings
- Follow the instructions in Get started with Tag Assistant Recordings to install the extension and record a flow on your website. (It's not important that the flow be recorded inside or outside of your corporate network.)
- Step 8 of those instructions tell you to open the Google Analytics Report tab. Do that, then click Change location in the left hand menu panel.
- Enter an IP address you expect your filter to exclude.
- Click Update.
Tag Assistant Recordings will reanalyze your report as if the hits came from the IP address you entered. If you set up your IP filter correctly, then the report should show all hits to this view filtered out.