googleanalytics / ga-dev-tools

A showcase of demos and tools built with the various Google Analytics APIs and Libraries.
https://ga-dev-tools.web.app/
Other
1.4k stars 561 forks source link

userEngagementDuration metric shows wrong values with medium dimension usage. #990

Open romanyehorov opened 2 years ago

romanyehorov commented 2 years ago

Using explore tab at analytics page I've noticed that "User Engagement" parameter completely different from my API response. I've thought that the error is in my code, so I've tried to re-check the request using https://ga-dev-tools.web.app/ga4/query-explorer/ and "try this method" tab at https://developers.google.com/analytics/devguides/reporting/data . They both gave me same number that was different from the explore tab. This metric works fine with all other dimensions, the issue appears only when combining with medium dimension. All the dates,conditions, queries, were re-checked multiple times, all other types of metrics work fine, every number matches with report in explore tab, except of this one userEngagementDuration. Also, bug reproduces only at Analytics Reporting API in batchRunReports method, at Google Analytics Data API with method runReport the parameter SessionDuration is the same as in report at explore tab. So the issue is only at Analytics Reporting API and userEngagementDuration parameter.

Screenshot 2022-10-12 at 22 34 37 Screenshot 2022-10-12 at 22 34 16 Screenshot 2022-10-12 at 22 34 00

dugwood commented 1 year ago

Struggling with this too... I think that the time shown in the web interface is divided by the number of totalUsers.

For example, I get through the API:

In the web interface, I see:

If I divide userEngagementDuration by totalUsers I get: 7467891 / 243959 = 30,61 seconds.

Not sure it's the right computation to make, but so far it seems to give the right result.

And looking at the HTML source on web interface, we can read that «Users» are activeUsers and «Engagement» is userEngagementDurationPerUser which doesn't exist in the API :-)

New try with activeUsers instead of totalUsers: 7467891 / 241059 = 30,97 seconds (should be rounded to 31 seconds, so I'll stay with totalUsers instead of activeUsers).

vgibara commented 1 year ago

Anyone got a solution with this ?

I have an example with a page:

userEngagementDuration (1144) / totalUsers (31) = 36s and Analytics UI = 1m 10s

And i confirm this is for the exact same date range, with a specific URL. How can i get the right information ?