To filter out internal traffic, create a rule that defines the IP address or range of IP addresses that represent internal traffic.
The definition of internal traffic that you create with these rules serves as the basis for your filters to include or exclude internal traffic.
When you create a definition of internal traffic, the traffic_type
parameter is automatically added to all events and has the parameter value you specify. You can also manually add the traffic_type
parameter to your event code (e.g., by modifying your gtag.js code) and give it any value you want.
Steps
- Identify internal traffic in your web data stream.
- Exclude internal traffic using a data filter at the property level.
Create filters in Analytics
Create definition
- Sign in to Analytics.
- In Admin, look at the Account and Property columns to make sure that you've selected your desired account and (Google Analytics 4) property.
- In the Property column, click Data Streams, and then click the web data stream for which you want to define internal traffic. (This option is not available for app data streams.)
- Under Additional Settings > More Tagging Settings, click
.
- Click Define internal traffic.
- Click Create.
- Enter a name for the rule.
traffic_type
is the only event parameter for which you can define a value.internal
is the default value, but you can enter a new value (e.g.,emea_headquarters
) to represent a location from which internal traffic originates.- Under IP address > Match type, select one of the operators (e.g., IP address equals).
- Under IP address, enter an address or range of addresses that identify traffic from the location you identified in Step 8. You can enter IPv4 or IPv6 addresses.
The following examples show how to identify IP addresses for each operator:- IP address equals: 172.16.1.1
- IP address begins with: 10.0.
- IP address ends with: .255
- IP address contains: .0.0.
- IP address is in range (ranges need to be expressed in CIDR notation):
- 24-bit block (e.g., 10.0.0.0 – 10.255.255.255): 10.0.0.0/8
- 20-bit block (e.g., 172.16.0.0 – 172.31.255.255): 172.16.0.0/12
- 16-bit block (e.g., 192.168.0.0 – 192.168.255.255): 192.168.0.0/16
- Click Create.
Using CIDR notation
Classless Inter-Domain Routing (CIDR) notation is a way to represent ranges of IP addresses.
The following examples use IPv4 addresses. CIDR-notation syntax is the same for IPv6 addresses.
IPv4 addresses are 32-bit binary numbers with the values for each octet ranging from 0-255.
For example, the IPv4 address
10.10.101.5
has the 32-bit binary equivalent of
00001010.00001010.01100101.00000101
When you express a range of IP addresses in CIDR notation, you indicate how many of the bits are fixed and how many can be of any value. For example, the CIDR notation for the range of addresses 192.128.255.0 - 192.168.255.255 is 192.168.255.0/24.
/24 indicates that the first 24 bits (192.128.255) are fixed and the last 8 bits (.0) are wildcards that can take any value (0 is the standard wildcard).
If you needed to indicate a range of 192.168.0.0 – 192.168.255.255, you would indicate that the first 16 bits of the address are fixed: 192.168.0.0/16.
/16 indicates that the first 16 bits (192.168) are fixed and the last 16 bits (.0.0) are wildcards that can take any value.
If you were using IPv6 addresses and wanted to express a range, you would use the same "slash-number" suffix to indicate how many bits of the range are fixed. For example, if the range were 0:0:0:0:0:ffff:c080:ff00 - 0:0:0:0:0:ffff:c080:ffff, you would express the range as 0:0:0:0:0:ffff:c080:ff00/120 (the first 120 bits are fixed).
Learn more about CIDR notation.
Edit definition
- Sign in to Analytics.
- In Admin, look at the Account and Property columns to make sure that you've selected your desired account and (Google Analytics 4) property.
- In the Property column, click Data Streams, and choose the web data stream for which you want to edit the internal-traffic definition.
- Under Additional Settings > More Tagging Settings, click
.
- Click Define internal traffic.
- Click the row for the definition.
- Click
.
- Make the changes you want, then click Save.
Delete definition
- Sign in to Analytics.
- In Admin, look at the Account and Property columns to make sure that you've selected your desired account and (Google Analytics 4) property.
- In the Property column, click Data Streams, and choose the web stream for which you want to define internal traffic.
- Under Additional Settings > More Tagging Settings, click
.
- Click Define internal traffic.
- Click the row for the definition.
- Click
> Delete.