Search code examples
google-analyticsgoogle-analytics-api

Daily/Weekly/Monthly Active Users on Google Analytics API


I am creating a dashboard to show both Monthly Active Users and Weekly Active Users from Google Analytics.

To query this data I am using the following parameters:

{
  "ids" => @account_id,
  "start-date" => start_date.to_s,
  "end-date" => end_date.to_s,
  "metrics"=> "ga:users",
  "samplingLevel" => "HIGHER_PRECISION"
}

For example, to get Weekly Active Users for each day I'm passing a 7 day interval and for Monthly Active Users I'm using 30 day interval.

The point is that numbers are significantly different comparing to what I've seen in the interface at Audience > Active Users.

I couldn't figure out a query to get the same data from the interface. Do you have any idea?

thanks :)


Solution

  • I don't think they're currently documented, but you can actually use the following metrics in your API requests:

    • ga:1dayUsers
    • ga:7dayUsers
    • ga:14dayUsers
    • ga:30dayUsers

    Note that ga:1dayUsers and ga:users are essentially the same thing, but ga:users and any of the active users metrics cannot be combined in the same request, so if you want to compare you should use ga:1dayUsers.

    Update

    Queries that use any of the active users metrics mentioned above must be combined with a day dimension (e.g. ga:date) in order to work.