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 :)
Ways to Track User Activity on a Website Tools like Google Analytics and Search Console. Click tracking (recording which elements on a page users click) Scroll tracking (recording where users scroll on a page) Viewing session recordings of users as they use their site.
Under Customization > Custom Reports, you'll see the Hourly & Daily Engagement (Hour, Day & Date) option. Click it.
First, we want to get the DAU and the MAU data from Google Analytics (GA). Select 'Cloud Apps Data' from the Data Frames menu. Select 'Google Analytics' data source. Select the appropriate account, property, and view.
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.
The following code should be able to help you collect this data in a single dataframe.
Please note that more than 1 type of variable cannot be captured in the query i.e. at a time, only one of the 1/7/14/28/30 day users can be queried.
At any given point in this on a particular date, the data will be rolled up i.e. If you observe 14 day User data on say 15th of the month then it will be unique users from 1st to 14th. for 16th this will be from 2nd to 15th and so on.
Hope this helps. R Code:
unique_1dayUser_data<-google_analytics(ga_id_raw,date_range=c(start_date,end_date),metrics=c("1dayUsers"),dimensions=c("date"))
unique_7dayUser_data<-google_analytics(ga_id_raw,date_range=c(start_date,end_date),metrics=c("7dayUsers"),dimensions=c("date"))
unique_14dayUser_data<-google_analytics(ga_id_raw,date_range=c(start_date,end_date),metrics=c("14dayUsers"),dimensions=c("date"))
unique_28dayUser_data<-google_analytics(ga_id_raw,date_range=c(start_date,end_date),metrics=c("28dayUsers"),dimensions=c("date"))
unique_30dayUser_data<-google_analytics(ga_id_raw,date_range=c(start_date,end_date),metrics=c("30dayUsers"),dimensions=c("date"))
unique_user_data<-cbind(unique_1dayUser_data,unique_7dayUser_data$`7dayUsers`,unique_14dayUser_data$`14dayUsers`,
unique_28dayUser_data$`28dayUsers`,unique_30dayUser_data$`30dayUsers`)
colnames(unique_user_data)<-c("Date","1 Day users","7 Day users","14 Day users","28 Day users","30 Day users")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With