Accessing Google Analytics API data from javascript without authentication

I want to access Google Analytics data through my API using Javascript. Basically I want to display on the website a list of the most visited pages for the last week / month. I can only use javascript for this.

I found this example on the official site http://code.google.com/p/google-api-javascript-client/wiki/Samples#Google_Analytics_API

Is there a way to access Google Analytics data without authentication? Do I need to load username / password somehow? To be clear, I want the website (tracking Google Analytics) to load analytics data from its own account.

I thought there might be a way to make certain data public and then request that somehow ... Or perhaps create a restricted user to access it. I can't find examples either.

+3


source to share


1 answer


You cannot access GA authentication using the same reason that you cannot access your bank account without being authenticated (as this would allow everyone else to access your account without being authenticated, which could cause some inconvenience).

Google provides a complete example of GA access via Javascript: https://developers.google.com/analytics/solutions/articles/hello-analytics-api . However, I don't think what you want (I think you need to google to actually fetch the data for that).



However, you can use Google Apps Script to fetch the data into a Google spreadsheet and insert it into your page (at least I think it should be safe).

Updated: Google has since released the Google Analytics superProxy , which allows you to securely share Analytics data with the public.

+6


source







All Articles