Search code examples
python-3.xgoogle-analyticsgoogle-analytics-api

Checking how many sessions are below 10 seconds using google analytics api?


The api variables can all be found in the attached link.

https://developers.google.com/analytics/devguides/reporting/core/dimsmets

If I'm creating a little python script that checks for the amount of sessions in a month that were under 10 seconds what variables would I need to use? I thought month would be it but that seems to give the total amount of session durations for the month. I can't use users or sessions as a dimension unfortunately.

report = analytics.get_monthly_report(client, month,
                                               ['ga:month'],
                                               ['ga:sessionDuration']
                                               )

Solution

  • You can use the session duration bucket dimension instead of the session duration metric to find this data.

    The session duration metric would be useful if you had a specific session scoped dimension that would make each row of data unique. It is a sum because you're using the month dimension.