I want to embed Google Analytics charts into my website so that from the admin console I can view certain analytics charts without needing to log into the Analytics console. I have come across the Analytics data API which requires OAuth to make it work but the problem is that I want any user with admin access to be able to see the analytics data without needing to register them into Google Analytics (which means OAuth won't work).

Does anyone know how I can achieve this. Would prefer a straight javascript solution rather than needing to route it through the web server.

Thanks in advance.

  • 1
    Here's tutorial mate. -> ga-dev-tools.appspot.com/embed-api/third-party-visualizations
    – Josip Ivic
    Commented Jul 19, 2016 at 11:28
  • I have already reviewed that tutorial and it uses OAuth which requires the end user to be logged into Google and to have access to the Analytics records through their Google account to get access to the data which I stated in the question I do not want. Whatever solution is offered I need it to be in such a way that I can specify an access code for my own Google Analytics account as a read only connection to show the data to the end user without needing them to log into Google Analytics using OAuth which would require me granting each of them access and would allow access to the Analytics site Commented Jul 19, 2016 at 21:44
  • I'd be curious to hear from SE staff regarding how SE tacked this problem as I understand the analytics privilege provides access to GA data in a similar way. Commented Jul 21, 2016 at 3:10

2 Answers 2


Okay, having gone through all the documentation and having spoken to Google I have found out that this is not possible at this time. Due to the inherent insecurity of javascript Google does not recommend directly providing read access to the data through a javascript API without some high level of security. The only way Google provides access to this data through the javascript API is with an OAuth authenticated session which requires the user to be logged into Google at the time plus having at a minimum read access to the Analytics profile.

As an alternate solution to this having done a range of research online I came across a good alternative named Piwik which is a PHP based website analytics engine which works much the same as Google Analytics but which runs on your own server as a PHP web application and is a lot easier to embed reports from. In Piwik I have been able to directly embed reports using <iframe> and I only need to pass a token code for a read only user to the iframe source URL to enable accessw. The beauty about this is that I am not limited to certain reports only, rather any chart, graphic, or report which I can access through the Piwik application I can embed in my site using an iframe as well as being able to directly query the data using the API.


I stopped using Google Analytics, but they may still have an email feature that you can setup to send you regular notifications on stats. If you can use that, set up a way to get those emails auto posted to your website some place.

  • They do still have the email feature available and while theoretically this would be possible to use it would still require a substantial amount of effort on the server side as I would need to have a mailbox configured to receive the emailed reports sent through in CSV format. Then I would have to have a scheduled task run regularly to read the email and download the attachment, which would then need to be extracted, read (as CSV) and then saved to the database, which for a high traffic site would be a lot of records being processed... Commented Jul 22, 2016 at 4:02
  • Additionally this would not provide access to the near real time data that could be accessed through the API as the data would be delayed due to email sending delays and then processing into the database. On top of all of that the analytics data which should be living in the analytics server would be duplicated in the website database causing an otherwise small database to balloon out simply from analytics data. Commented Jul 22, 2016 at 4:03
  • Of course it's not an answer. I know that and so do you. But stack exchange won't let me make a comment. But back on topic man, it surely is better than nothing. If you need constant real time api access like that, then the answer Should be the asker can turn to google paid support. It is a money makin product after all. Commented Jul 26, 2016 at 18:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.