Sub topic 3
Choosing an IP Match Type in GA4
This chapter assumes that you have a GA4 web data stream, Editor or Administrator access, and the public IP addresses used by your office or other internal network. You should also understand that GA4 collects events, groups them into sessions, and assigns traffic sources.
An internal traffic rule uses an IP address to identify visits from your organization. The rule then assigns those events a value such as traffic_type=internal. A property-level data filter can use that value to exclude the events from reporting.
Choose the match type that fits your address
GA4 offers several ways to compare an incoming IP address with the address in your rule. Choose the simplest match type that covers your known addresses without matching unrelated visitors.
| Match type | Best use | Example | Column | Column |
|---|---|---|---|---|
| IP address equals | One fixed public IPv4 or IPv6 address | `203.0.113.42` | ||
| IP address is in range | A contiguous network block | `203.0.113.0/24` | ||
| Regular expression | A carefully defined set or pattern of addresses | `^203\.0\.113\.([1-9] | [1-9][0-9] | 1[0-9]{2})$` |
Use an exact address for one fixed IP
Choose IP address equals when your organization has one stable public address. This is common for a small office or a VPN gateway with a dedicated address.
An exact match is easy to review and has a low risk of excluding genuine users. Its limitation is maintenance. If your internet provider changes the address, the rule stops matching until you update it.
IP address equals: 203.0.113.42Do not enter a private address such as 192.168.1.20. GA4 receives the public address presented by your network, not the device's private address inside the office.
Use CIDR for a contiguous range
CIDR, or Classless Inter-Domain Routing, is a notation for an IP network and its size. Use it when your office or provider assigns a block of adjacent public addresses.
For example, 203.0.113.0/24 represents addresses from 203.0.113.0 through 203.0.113.255.
IP address is in range (CIDR notation): 203.0.113.0/24CIDR is usually preferable to writing many exact rules. Confirm the range with your network administrator or provider. A range that is too broad can remove traffic from other organizations that use addresses outside your control.
IPv6 addresses can also be long and easy to mistype. Copy them from a trusted network record, and test the rule with a real connection before activating the filter.
Use a regular expression only when necessary
A regular expression, or regex, describes a text pattern. It can match a selected set of addresses when an exact match or CIDR range does not express the requirement clearly.
For example, this pattern matches addresses from 203.0.113.1 through 203.0.113.199:
^203\.0\.113\.([1-9]|[1-9][0-9]|1[0-9]{2})$The ^ and $ anchors require the whole address to match. The backslashes before the dots make them literal dots. Without them, a dot in a regex can match another character.
Regex rules are harder to audit. Avoid a broad pattern such as 203\.0\.113\..* unless every address in that network belongs to your organization.
Decide between precision and maintenance
Use this decision path:
Record the addresses, match types, and owners in your property documentation. When a rule stops matching, check whether the network changed before changing the GA4 filter.
Exercise
Your office uses public addresses from 198.51.100.64 through 198.51.100.127. Which match type should you prefer, assuming the whole block belongs to your organization?
Show answer
Use a CIDR range, 198.51.100.64/26. It represents the contiguous 64-address block and is easier to maintain than separate exact-address rules.