Tutorial: IP Anonymization in Conversions API: Meta, LinkedIn, and TikTok
Adherence to global privacy standards necessitates the anonymization of IP addresses before transmission to advertising platforms. This document outlines the procedure for masking IP addresses within the Server-Side Google Tag Manager (ssGTM) environment for Meta, LinkedIn, and TikTok Conversions API integrations.
Step 1: Implementing IP Masking Logic
The anonymization process involves stripping the last octet of the IPv4 address (or the equivalent segment of an IPv6 address). This is typically performed using a Custom Template in ssGTM. The transformation function replaces the last portion of the string with “0”.
function maskIP(ip) {
return ip.replace(/\.\d+$/, '.0');
}
Step 2: Applying Masking to Payload
Within the CAPI tag configuration, the client_ip_address field is mapped to a variable containing the result of the masking function, rather than the raw HTTP request IP.
Step 3: Platform Specifics
- Meta (Facebook): The
client_ip_addressparameter is masked before being sent within the event payload. - LinkedIn: The
user.ipfield is transformed. - TikTok: The
ipfield within theuserobject is masked.
Payload Example
Raw Payload (Before Masking):
{
"client_ip_address": "192.168.1.45",
"event_name": "Purchase"
}
Masked Payload (After Masking):
{
"client_ip_address": "192.168.1.0",
"event_name": "Purchase"
}