# IP anonymization

Also called: IP masking, IP truncation, anonymize IP, anonymize_ip, IP anonymisation

IP anonymization, also called IP masking, removes part of a visitor's IP address before it is stored, so the stored value points to a network block rather than a single connection. The usual method sets the last octet of an IPv4 address to zero, which leaves 256 possible addresses.

## How it is 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](https://support.google.com/analytics/answer/2763052) 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.

```
IPv4: a.b.c.d → a.b.c.0 (8 of 32 bits removed, 256 addresses per value)
```

## Example

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.

## How CrispStats shows it

CrispStats does not mask IP addresses: it does not store them at all. The address is read at the edge to compute the daily visitor hash (with a random salt that is deleted after its day), an approximate location rounded to about 11 km and rate limits, then discarded. To keep an office out of your reports, add its address under Excluded IP addresses: that list is your own setting, and visitor addresses are still not stored.

## Related terms

- [Visitor hash](/glossary/visitor-hash)
- [Personally identifiable information](/glossary/personally-identifiable-information)
- [GDPR](/glossary/gdpr)
- [Cookieless tracking](/glossary/cookieless-tracking)
- [Data retention](/glossary/data-retention)
- [Browser fingerprinting](/glossary/browser-fingerprinting)
- [User agent](/glossary/user-agent)
