How is it calculated?
For IPv4, the last 8 bits are replaced with zeros: 12.214.31.144 becomes 12.214.31.0. For IPv6, more is removed because each block is larger. Google’s help page on IP masking describes this exact scheme for Universal Analytics: the last octet of IPv4 and the last 80 of 128 bits of IPv6 were zeroed, in memory, before anything was written to disk. It was opt-in, through anonymize_ip.
The same page says Google Analytics 4 does not log or store IP addresses, so the setting is not needed there. Masking reduces precision; it does not make data anonymous in the legal sense. A truncated address combined with a timestamp, user agent and page path can still narrow down to one person, so it is safer to keep treating it as personal data.
Example
- 255 other addresses
- 12 people
A visitor at 81.2.69.142 loads a page. With masking, 81.2.69.0 is stored, shared with up to 255 other addresses in that block. If the block belongs to one small office of 12 people and the record also holds the time, browser and page, picking out the person is easy. Without storing the address at all, there is nothing to narrow down.
Common mistakes
- Calling masked IPs anonymous. A /24 block plus other fields can still identify someone, so treat it as personal data.
- Still turning on IP anonymization in GA4. Google says GA4 does not log or store IP addresses, so there is nothing to mask there.
- Hashing an IP address without a salt and calling that anonymous. There are only about 4.3 billion IPv4 addresses, so every hash can be reversed by trying them all.