4

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?

Pratik Gadoya
  • 1,420
  • 1
  • 16
  • 27
GarouDan
  • 3,743
  • 9
  • 49
  • 75
  • Looks like analytics api just returns hour visitors. Is it correct? How can I get the real time visitors number? – GarouDan Dec 12 '12 at 12:14
  • If you don't want to get involved with the API check out http://www.embeddedanalytics.com - we have a bunch of reporting widgets that are real-time based. – M Schenkel Jan 28 '17 at 02:45

4 Answers4

4

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

John
  • 29,788
  • 18
  • 89
  • 130
3

Access to the real-time data is not yet available through the api. See the following:

Access to Real Time data

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/

Community
  • 1
  • 1
jk.
  • 14,365
  • 4
  • 43
  • 58
  • 1
    As @jk alludes, Real-time data is not yet available. I think the best you could do is to query for a single date and then group by hour. – M Schenkel Dec 14 '12 at 03:02
2

Embed API - Third Party Visualizations

enter image description here

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/

elp
  • 8,021
  • 7
  • 61
  • 120
1

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.

Community
  • 1
  • 1
A.M.K
  • 16,727
  • 4
  • 32
  • 64