Google Analytics (particularly version 4, "GA4") has various predefined events, each with its own parameters. E.g. the purchase
event has an items
parameter, which contains data such as item_id
and item_name
for each purchased item. JS code on a website can send these events and pass the extra data, and I can actually see the data in the "Analysis hub" in the Google Analytics interface.
Is there a way to also fetch this extra data using the Google Analytics Data API? There is a way to retrieve some predefined dimensions and also "custom dimensions" (via customEvent:parameter_name
), but e.g. purchase item data doesn't seem to be a part of that.
Do I have to define custom dimensions (e.g. a purchasedProductId
) and send them in addition to the items
parameter, if I want to access this data via API?
AlphaAnalyticsDataClient
, where I tried to create aRunReportRequest
withdimensions=[Dimension(name='item_id')]
and various variations of that name (itemId
,productItemId
,customEvent:item_id
, etc.), but I'm always gettinggoogle.api_core.exceptions.InvalidArgument: 400 Field ... is not a valid dimension. For a list of valid dimensions and metrics, see https://developers.google.com/analytics/devguides/reporting/data/v1/api-schema
. – Jan Pöschko