I would like to show number of visitors on a site since beginning of the month, number of users on the current day and currently on site.
I have Google Analytics installed, I tried to solve this issue with Embed API by enabling Google Analytics API from developer console - but I requires user authorization, etc.
Thank you for any suggestion.
Authorization has to happen in order to get the data you want. Either you can let visitors to your site authorize themselves, or you'll have to authorize server-side on their behalf.
Once authorized, you can do something similar to what the Third Party Visualization Embed API demo shows. It uses a custom
ActiveUsers Embed API component and includes the source code to show how it works.
Whether you use the
ActiveUsers component or not, the basic gist is that once the users is authenticated via the Embed API, you have access to the method
gapi.client.analytics.data.realtime.get, which you can use to query this data.
Here's where that happens in the source code for the