Reputation: 51
I am using Python API to retrieve information to generate analytics report for an app. We are using the new GA4.
Sending the event parameter : Event Category, Event Action, Event Label and Event Value
through the gtag.js while triggering the event.
The parameters are labelled as follows: Category, Action, Label, Value
Now, once the events are triggered, I need to collect all the information about the events from GA4 and make a my own report using Python API calls. I need the information of all the Event Label and Event Value which was passed through gtag.js
I am using:
request = RunReportRequest(
property=f"properties/{property_id}",
dimensions=[Dimension(name="eventName")],
metrics=[Metric(name="eventCount")],
date_ranges=[DateRange(start_date= sdate, end_date= edate)],
)
client = BetaAnalyticsDataClient()
response = client.run_report(request)
This will just give the Event Name and the count of the events that occurred.
I read that in GA3, eventLabel, eventCategory and eventAction
are treated as dimensions and eventValue
as a metric. But seems like that's not the case in GA4.
I tried eventLabel
as the dimension in the dimension field in the request payload. It threw me error saying its not a valid dimension.
I tried eventValue
in metrics field and that would provide me the summation of all the Event Value for each event.
But I need the individual Values of each Event and also the Label corresponding to it. Is there any way that I can retrieve this information? Am I missing anything? Happy to share more info if required.
Any help is appreciated. Thanks in advance :)
Upvotes: 5
Views: 2584
Reputation: 14179
Here you can find how to instrument Universal Analytics events as Google Analytics 4 events: https://developers.google.com/analytics/devguides/collection/ga4/translate-events
GA4 events have no notion of Category, Action, and Label and, unlike in UA properties, GA4 reports do not display Category, Action, and Label. Therefore, it’s better to rethink your data collection in terms of the GA4 model rather than port your existing event structure to GA4.
Upvotes: 1
Reputation: 3125
Google Analytics 4 (GA4) has different data model than that of Universal Analytics (UA).
In UA data model is based on hits
where event is a type of hit in which you can pass the parameters (Category, Action, Label and Value), which are removed in GA4. GA4 has data model based on events
in which event name
and custom parameters needs to be passed.
Here are the links on how to send events in GA4 and available columns through API.
Upvotes: 1