The GA4 Measurement Protocol now allows overriding a user’s geographic location by either providing an IP address with the ip_override
attribute or using a user_location
object. The IP address used for ip_override
does not need to be the user’s actual IP but must geolocate to the same region. When both are provided, the user_location
object takes precedence over ip_override
.
Geographic Information Attributes
To specify geographic data for events, the user_location
object can include the following optional fields, with a recommendation to at least provide country_id
and region_id
:
Key | Type | Description |
---|---|---|
city | string | Optional. The city name. |
region_id | string | Optional. ISO 3166 country and subdivision code (e.g., US-CA, GB-LND). |
country_id | string | Optional. Country in ISO 3166-1 alpha-2 format (e.g., US, AU, FR). |
subcontinent_id | string | Optional. Subcontinent in UN M49 format (e.g., 021 for Americas). |
continent_id | string | Optional. Continent in UN M49 format (e.g., 019 for Americas). |
Example of user_location
Object
"user_location": {
"city": "Mountain View",
"region_id": "US-CA",
"country_id": "US",
"subcontinent_id": "021",
"continent_id": "019"
}
This update enables more precise control over geographic data in GA4 event measurement by allowing manual overrides of location information.