I'm using the 'Hello Analytics' code example found at [https://developers.google.com/analytics/devguides/reporting/core/v3/quickstart/web-js][1] to allow me to gain access to my Google Analytics account and log the JSON response to the console. I can traverse the JSON and see how to request specific data I want from the Core Reporting API... Its pretty awesome.
I'm more interested in the realtime data, however. For this particular project I need something faster than the core reporting API...
Questions: Is the Realtime Reporting API something that is accessible via javascript and if so, would it (generally speaking) also work in this same fashion? Meaning Is it just a matter of changing EITHER of the following to get the same type of response from the REALTIME api?
// Set authorized scope.
var SCOPES = ['https://www.googleapis.com/auth/analytics.readonly'];
or
// Load the Google Analytics client library.
gapi.client.load('analytics', 'v3').then(function() {
I see a good number of resources / examples for the core reporting API, but not much on the realtime API
The Core Reporting API and the Real time API work very much the same way, with the same authentication scopes even.
gapi.client.analytics.data.ga.get(...)
Core Reporting API method reference.
gapi.client.analytics.data.realtime.get(...)
Realtime API method reference.
The Realtime API has is its own set of dimensions and metrics that begin with rt:...
where the Core reporting API dimensions and metrics begin with ga:...
.