I am struggling with getting the currently active users from Reporting API v4 via JavaScript. I found this part of documentation which is dealing with it, where is it available as "rt:activeUsers", but it is for v3, not v4 - https://developers.google.com/analytics/devguides/reporting/realtime/dimsmets/. It seems like there is no such option available in documentation of v4 - https://developers.google.com/analytics/devguides/reporting/core/dimsmets#cats=user
Did I just overlook something? See my code below
<!-- API CALL -->
<script>
// VIEW ID
var view_id = '0000000';
var start_date = '7daysAgo';
var end_date = 'today';
// LOAD DATA FROM GOOGLE ANALYTICS
function loadAnalytics() {
gapi.client.request({
// CONFIGURATION
path: '/v4/reports:batchGet',
root: 'https://analyticsreporting.googleapis.com/',
method: 'POST',
// REQUEST
body: {
reportRequests: [{
// VIEW ID
viewId: view_id,
// DATA RANGE FOR RESULTS
dateRanges: [{
startDate: start_date,
endDate: end_date
}],
dimensions: [
{ name:"ga:browser" },
{ name:"ga:browserVersion" },
{ name: "ga:userType"}
],
// REQUESTED DATA
metrics: [
{ expression: 'ga:hits' },
{ expression: 'ga:users' },
{ expression: 'ga:newUsers' },
{ expression: 'ga:sessions' },
{ expression: 'ga:avgSessionDuration' },
{ expression: 'ga:percentNewSessions' },
{ expression: 'ga:sessionsPerUser'},
{ expression: 'ga:bounces' },
{ expression: 'ga:bounceRate' },
{ expression: 'ga:activeUsers'}
]
}]
}
// PUSH OBTAINED DATA TO DISPLAYING FUNCTION
}).then(prepareVariables, console.error.bind(console));
}