Reputation: 3833
Is there any way using gapi (preferable) to retrieve the real time visitors from Google Analytics?
I tried to pass a date range like:
begin: 2012-12-12 09:49:04 end: 2012-12-12 09:49:05
but it didn't work.
I did a research and couldn't find a solution yet.
Someone can help me?
Upvotes: 4
Views: 16054
Reputation: 8131
Embed API - Third Party Visualizations
The Embed API make it easy to query data and display it in a Google Chart. But it also allows you to access the raw data so you can display it however you want. This example uses the Chart.js visualization library.
The Embed API is built on top of the Google APIs client library, which means you don't just get access to the reporting API, you get access to everything.
In addition to showing Chart.js visualizations, this example uses the underlying client library to query data from the Real Time Reporting API.
You can take a look here: https://ga-dev-tools.appspot.com/embed-api/third-party-visualizations/
Upvotes: 2
Reputation: 16785
If you don't want to wait for the API to be publicly released and don't need to pull the data from third-party accounts then I reverse-engineered the API used by the Analytics dashboard here:
https://stackoverflow.com/a/18945515/900747
As you can see in the answer it's hardly a stable API but it should provide everything you need, assuming that this is for personal use.
Upvotes: 1
Reputation: 30586
Google has now launched a real time API. It is only in beta however you can sign up and should be available to everyone later.
http://analytics.blogspot.co.uk/2013/08/google-analytics-launches-real-time-api.html
Upvotes: 4
Reputation: 14435
Access to the real-time data is not yet available through the api. See the following:
Scraping Real Time Visitors from Google Analytics
The only way to get it currently is to look at it in the Google Analytics web interface: https://www.google.com/analytics/web/
Upvotes: 3