GA4 enables you to filter out internal traffic in web data streams. 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 is used to set the traffic_type
parameter which can then be used in 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
- Create a rule to identify internal traffic in your web data stream.
- Create a filter at the property level to exclude internal traffic.
Create a rule to identify internal traffic
- In Admin, click Data Streams in the Property column.
- Click Web and then click a web data stream.
- In the web stream details, click Configure tag settings (at the bottom).
- Click Show all.
- 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 IP address field does not support the use of regular expressions (regex).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
- You can set multiple conditions to identify internal IP addresses using the Add condition button.
If multiple conditions are set, they are joined by an implied OR operator. In other words, IP addresses that match any one of the conditions will be marked as internal traffic.
- 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 your internal traffic definition
- In Admin, click Data Streams in the Property column.
- Click Web and then click a web data stream.
- In the web stream details, click Configure tag settings (at the bottom).
- Click Show all.
- Click Define internal traffic.
- Click the row for the definition.
- Click
.
- Make the changes you want, then click Save.
Delete your internal traffic definition
- In Admin, click Data Streams in the Property column.
- Click Web and then click a web data stream.
- In the web stream details, click Configure tag settings (at the bottom).
- Click Show all.
- Click Define internal traffic.
- Click the row for the definition.
- Click
(in the top right).
- Click Delete.