How to set User Agent in Measurement Protocol (Google Analytics 4)
Asked Answered
D

2

9

How to set or override User Agent value in Measurement Protocol (Google Analytics 4)?

It was easy with previous Measurement Protocol (Universal Analytics): https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters?hl=en#ua

But it is not clear to me how to send User Agent to Google Analytics v4.

Dilorenzo answered 11/12, 2020 at 10:45 Comment(1)
Documentation of new Measurement Protocol developers.google.com/analytics/devguides/collection/protocol/… with no answer to my question.Dilorenzo
H
2

If you check the documentation at the top of the page Measurement Protocol (Google Analytics 4)

enter image description here

You will see that this protocol is still in alpha and is extremely limited there is a lot we cant do with it.

As of the time of posting this answer the answer is you cant. I suggest you wait a while as time goes on the team will begin to add new features.

Hardpan answered 11/12, 2020 at 10:54 Comment(7)
It is impossible to create Universal Analytics resource in Google Analytics UI, so it is required for all users to use Analytics v4. Thus I have to use Measurement Protocol (Google Analytics 4).Dilorenzo
Then you are limited by what you can add with the Measurement protocol for (Google Analytics ga4). There is not much more you can do then wait for them to release a new version of the Measurement protocol with the missing features. I have also sent in a request for additional features. you can submit feature requests hereHardpan
You can still create Universal properties in GA. Create a new property, it will bring up a Property Setup page, click the Show advanced options link towards bottom of the Property Setup page to access and toggle on the Create a Universal Analytics property options. Once you toggle on the Create a Universal Analytics property option, there's the choice of Create both a Google Analytics 4 and a Universal Analytics property, or Create a Universal Analytics property onlyHomesick
Im surprised Google made the GA4 variant the default for new properties, and then promote it so heavily, even though the API for it is basically useless, even months later there has been no new developments. Since the User Agent, and other client side properties are automatically collected via their own gtag.js client, I suggest look at the events it generates as this will include the fields names used by the API, even though they are undocumented on their docs website.Longo
Having now examined the gtag.js funcionality, they are using the Universal Analytics Measurement Protocol (not v4), BUT, they are using an undocumented version '2'. So by just setting that, along with the GA4 measurement ID, I found the UA protocol would be accepted and show up normally in the GA4 property. It appears Google must translate the event internally.Longo
I am not a Google employee but they probably prioritize user experience above third party developers. They API is being constantly worked on. If there is something that you miss desperately let me know I have contacts with the team working on the API i can try to bring it up to them for you.Hardpan
Nearly two years later and still no additional features in GA4's Measurement Protocol. @LindaLawton-DaImTo It would be great to have a possibility to send the user agent and override the location (as possible in UA developers.google.com/analytics/devguides/collection/protocol/…). As a result, both data should be splited into they parts (browser, version, system,... and country, city, state, ...).Heathenize
D
0

You can't. Many years into the launch of the GA4 Measurement Protocol API, the answer is still no. Here is the official confession from Google:

https://developers.google.com/analytics/devguides/collection/protocol/ga4/ua-feature-matrix#user_agent_override

Define answered 26/4, 2024 at 8:0 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.