You can use the Transformations feature in your server-side Google Tag Manager (SGTM) container to modify or anonymize the IP address before the data is sent from your server to Google. This allows you to redact signals before any individual tag accesses the data.
On this page
- Override IP addresses for Google tags using Transformations
- Override IP addresses for non-Google tags using Transformations
Override IP addresses for Google tags using Transformations
- In Google Tag Manager, open your server workspace.
- Click Variables and click New. Create a Custom Template Variable to anonymize the IP address using the following JavaScript:
const getAnonymizedIpAddress = require('getAnonymizedIpAddress');
return getAnonymizedIpAddress();
- Click Transformations.
- Click New.
- Select the Augment event transformation. Set it to override the
ip_overridefield, mapping it to the variable you created. - Under Matching Conditions or Affected Tags, select the tags that should receive the partially redacted IP (for example, Google Ads, Floodlight, or other non-Google tags).
- Note: Google Analytics server tags already apply partial IP redaction by default.
- Click Preview. Trigger your tags and verify that the IP address is redacted before the data leaves the server.
- Save the transformation and publish your server container.
Override IP addresses for non-Google tags using Transformations
Many major third-party tag templates are designed to read the IP address directly from the standard ip_override field. If your third-party tag does this, the transformation you created for your Google tags will automatically apply to those third-party tags as well.
Not all third-party vendors use the
ip_override field. Some tags may extract IP addresses from alternative custom headers or specific event parameters. Verify how your specific vendor collects the IP address and, if necessary, apply a transformation to their custom field.- Review your third-party tag's documentation or use Tag Assistant to inspect incoming requests. Check if the tag reads the IP address from the standard
ip_overridefield. If it does, the setup you did for your Google tags is sufficient. - If the tag doesn’t use
ip_override, identify the specific event data field the tag uses to collect the IP address. - In your server container, click Transformations.
- Click New.
- Select the Augment event transformation. Instead of the standard
ip_override, set it to override the specific custom field you identified in step 2. Map this field to the IP anonymization variable you created. - Under the Matching Conditions or Affected Tags, specify the exact third-party tags that should receive the anonymized IP.
- Click Preview. Trigger your tags and verify that the specific field used by your third-party tag is redacted before the data leaves the server.
- Save the transformation and publish your server container.