[UA] IP masking in Universal Analytics [Legacy]
Short summary
Universal Analytics offers an IP-address masking feature that truncates user IP addresses to enhance privacy and comply with data protection regulations. The process occurs in memory before any data is stored, ensuring full IP addresses are never recorded. Website owners can implement this feature using the anonymize_ip configuration in the gtag.js library.
- IP masking zeroes out the last octet of IPv4 addresses and the last 80 bits of IPv6 addresses almost immediately after Google Analytics receives the data.
- Truncation happens in memory before any storage occurs, so the full IP address is never written to disk.
- Enabling the feature only requires setting the anonymize_ip parameter (aip=1) via gtag.js.
- Even with masking, enough geographic information survives in the truncated address to still support location-based reporting.
Full summary
Universal Analytics offers an IP-address masking feature designed to enhance user privacy by truncating user IP addresses before any data is stored or processed. This feature is particularly useful for website owners seeking to comply with privacy policies or local data protection regulations that restrict the retention of full IP addresses. When enabled, the last octet of IPv4 addresses and the last 80 bits of IPv6 addresses are set to zeros shortly after the data is received by Google Analytics, ensuring that the full IP address is never written to disk.
The process of IP masking occurs within two key steps in the data collection pipeline: the Analytics JavaScript Tag and the Analytics Collection Network. When a webpage containing the Analytics tag is loaded, it triggers the execution of various configuration functions, including the masking of IP addresses if the specific parameter (aip=1) is set. This ensures that as the data is sent to Google Analytics, the IP address is truncated right in memory before any storage occurs.
The Analytics Collection Network plays a vital role in this process by handling requests for the JavaScript library and collecting data from users. Upon receiving a request, the network immediately holds the IP address in memory for truncation. If the masking function is activated, the address is modified to hide the last octet or bits, thereby safeguarding user anonymity. This meticulous approach guarantees that at no point is the complete IP address stored, effectively maintaining user confidentiality while still allowing for geographic dimensions to be derived from the truncated information.