#GTMTips: Override Google Analytics 4 Fields in Server-Side GTM

You can use the GA4 tag in server-side Google Tag Manager to override some of the default fields set in the incoming data stream.

Server-side tagging is all about control. Being able to intercept, modify, and even block requests as they come in before they are dispatched to their actual endpoints is extremely valuable.

The built-in Google Analytics 4 tag template has options for modifying event parameters and user properties in the Google Analytics 4 request, but did you know you can use these options to modify some of the fields as well, such as Client ID, User ID, and event Engagement Time?

In this article, I’ll build a comprehensive list of all the fields you can edit. Please let me know in the comments in case you find fields that I might have missed, and I’ll add them to the list.

Tip 135: Override fields in the GA4 tag using SGTM

To edit the fields, you need to use the option under Event Parameters labeled Parameters to Add / Edit. This will not work if you try to add the fields under User Properties.

To add or edit a field, consult the list below. The field names are derived from the Event Data object. Not all fields in the Event Data object can be edited.

Take a look at the screenshot above for an example of how to manually set the user’s IP address using the field ip_override.

Note that the GA4 tag automatically truncates the last octet of the IP address to 0, so setting it to 1.2.3.4 will have the same effect as setting it to 1.2.3.0.

Field name Description Sample value
campaign_content Campaign Content. my_campaign
campaign_id Campaign ID. cpb12345
campaign_medium Campaign Medium. email
campaign_name Campaign Name. january2023
campaign_source Campaign Source. newsletter
campaign_term Campaign Term. shoes
client_hints.mobile Client Hints API. 1 if device is mobile, 0 if not. 1
client_hints.platform Client Hints API. Platform name. macOS
client_id Google Analytics Client ID. 1234567.1234567
engagement_time_msec Engagement Time in milliseconds. 1000
ga_session_id GA4 session ID. 1680157606
ga_session_number GA4 session count. 4
ip_override User’s IP address. 192.168.1.1
language Browser language. en-us
page_location Page URL. https://www.simoahava.com/test/
page_referrer Page Referrer. https://google.com
page_title Page Title. My Home Page
user_agent User Agent string (gets set in the outgoing request headers). Mozilla/5.0 (Linux; Android 8.0.0; SM-G960F Build/R16NW) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.84 Mobile Safari/537.36
user_id GA4 User ID. my_crm_id_abc
x-ga-page_id Page ID. my_page_id_11111

The rule of thumb is that if the field is available in the Event Data object, which you can easily debug in server-side tagging Preview mode, you can override it using the event data key from that object.

However, I found that fields that begin with x-ga (GA’s own internal settings) cannot be overridden except for the elusive x-ga-page_id. This means that you can’t set a hit as a First Visit (x-ga-system_properties.fv) or as a Session Start (x-ga-system_properties.ss) unless the incoming stream already set those values.

Please let me know in the comments if I missed some fields. I’ll update the list accordingly.