Reputation: 562
I've made a python script to get the number of active users on my site, but I've recently found out that the number I get from GA4 is less than that of the regular GA.
For the information, I am getting the number of active users in the last 5 minutes, which I assume is the correct number regarding GA when it counts active users.
If I get the default duration, which is 30 minutes, then I get even more data.
As an example, in GA I have "310" active users at the moment, but on GA4, I have "83" in the last 5 minutes, and "448" in the last 30 minutes.
Here is my code:
#Runs a realtime report on a Google Analytics 4 property.
client = BetaAnalyticsDataClient()
#Run the request.
request = RunRealtimeReportRequest(
property=f"properties/{property_id}",
metrics=[Metric(name="activeUsers")],
minute_ranges=[MinuteRange(start_minutes_ago=29, end_minutes_ago=0)]
)
#Parse the response.
response = client.run_realtime_report(request)
Upvotes: 2
Views: 1357
Reputation: 32760
The two versions do not measure the same thing, with GA4 expected to show more users:
The Realtime report in Google Analytics 4 properties counts users who engaged with your app/site for any non-zero amount of time during the previous 30 minutes, while the Streamview (realtime) report in Universal Analytics Standard/360 properties counts any user who triggered an event during the previous five minutes.
Upvotes: 3