adswerve / GA4-Measurement-Protocol-Python

Google Analytics 4 Python Library for Measurement Protocol
BSD 3-Clause "New" or "Revised" License
58 stars 19 forks source link

Client ID description misleading? #31

Closed sk0g closed 2 years ago

sk0g commented 2 years ago

Are we sure the Client ID has anything to do with the ones you can generate in the Console, and not localist entirely to Google Ads? Per the piece of code describing client_id, it is the API Client ID that you have to generate once. This is also repeated in README.MD.

https://github.com/adswerve/GA4-Measurement-Protocol-Python/blob/c42cb0f62be6d7fea2f96e880559e513d7707672/ga4mp/ga4mp.py#L32-L33

I'm not entirely sure that is right however.

GA v4 [0] describes client_id as "Uniquely identifies a user instance of a web client", in contrast to user_id which is "A unique identifier for a user". So it's identifying the user + device combination. GA v3 [1] describes cid as "This field is required if User ID (uid) is not specified in the request. This pseudonymously identifies a particular user, device, or browser instance. For the web, this is generally stored as a first-party cookie with a two-year expiration. For mobile apps, this is randomly generated for each particular instance of an application install. The value of this field should be a random UUID...", which echoes the definition above, also greatly expanding it.

From both of those definitions, the Client ID field is a different thing to Google Console API Client ID. In fact, the wizard for creating the API keys does not even have options for Ads/Analytics/GA, or other similar keywords I tried. Providing a random value in the field would work, but it wouldn't be helpful for collating and aggregating the data as GA would be attempting to.

Mind you, I have roughly zero expectations in terms of accuracy or up-to-date-ness when it comes to Google documenting their APIs and products, so this could all well be completely wrong.

[0] https://developers.google.com/analytics/devguides/collection/protocol/ga4/reference?client_type=gtag#payload [1] https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters

UPDATE: Found some documentation further describing the expectations for the client_id field: https://developers.google.com/analytics/devguides/collection/protocol/ga4/verify-implementation?client_type=gtag#client_send

rptomey commented 2 years ago

You're correct. The previous version's description of what was expected for the client_id field was incorrect. This has been fixed in the newest major update.