LW IT Solutions
« Blog Overview /Digital Marketing/Tutorials / Tutorial: IP Anonymization in Conversions API: Meta,...
This post in other languages:

Tutorial: IP Anonymization in Conversions API: Meta, LinkedIn, and TikTok

Tutorial: IP Anonymization in Conversions API: Meta, LinkedIn, and TikTok
Contents
  1. Step 1: Implementing IP Masking Logic
  2. Step 2: Applying Masking to Payload
  3. Step 3: Platform Specifics
  4. Payload Example
  5. Sources

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”.

IP masking chain: raw address through the mask function to the masked value and its three platform-specific field names
The masking is a single line, but it decides which category of data leaves the server. The same masked value then goes into three differently named fields.
function maskIP(ip) {
  const octets = ip.split('.');
  if (octets.length !== 4) {
    return undefined;
  }
  return octets.slice(0, 3).join('.') + '.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_address parameter is masked before being sent within the event payload.
  • LinkedIn: The user.ip field is transformed.
  • TikTok: The ip field within the user object 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"
}
Lukas Wojcik

Lukas Wojcik

Systems architect and technology enthusiast specializing in scalable tracking solutions, GMP Stack (GA4 & GTM), and robust backend architectures. Advocate for clean code and privacy-first design.

Get in Touch

Briefly describe your project or inquiry for a tailored response. This site is protected by reCAPTCHA.

2 comments

  1. Oliver Grantham

    Having the three platforms and their differing field names side by side is genuinely useful — client_ip_address, user.ip and the nested ip are easy to mix up when the same masked value feeds all three.

    About the function itself: anything that is not four octets returns undefined, so IPv6 traffic ends up with no IP at all. Is dropping the field the intended outcome, or should a masked IPv6 be sent instead?

    1. Lukas Wojcik Author

      Dropping it is the safe outcome and the right default — an unmasked address is the one failure that cannot be corrected afterwards. It is not a free choice, though, and the cost is measurable.

      All three platforms use the IP as one matching signal among several. Removing it for the IPv6 share lowers match quality for exactly that slice of traffic, and that slice is not small: on mobile networks it is frequently the majority. So the decision is between coverage and correctness, and it deserves to be made deliberately rather than inherited from a regular expression.

      Both routes are defensible. Implementing the IPv6 branch — zeroing the trailing segments, the equivalent of dropping the last octet — keeps the signal. Accepting the drop is fine too, as long as its size is known: a daily count of events sent without a client IP turns an invisible design decision into a number, and that number is what a later conversation about match quality will need.

Write a comment

The email address is not published. Required fields are marked with an asterisk.

ALL ARTICLES & CATEGORIES

CCTV

Follow this category by RSS

Cloud & AI

Follow this category by RSS

Data Privacy

All 11 articles in this category Follow this category by RSS

Digital Analytics

All 44 articles in this category Follow this category by RSS

Digital Marketing

All 25 articles in this category Follow this category by RSS

IT & Networks

All 15 articles in this category Follow this category by RSS

Raspberry PI

Follow this category by RSS

Smart Home

All 11 articles in this category Follow this category by RSS

Web Development

Follow this category by RSS

WordPress Plugins & Tricks

Follow this category by RSS