admin管理员组

文章数量:1278653

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

I found this example on the official site

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

I thought there might be a way to make certain data public, then query that somehow... Or perhaps create a limited user to access it. I can find no examples of either.

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

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

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

I thought there might be a way to make certain data public, then query that somehow... Or perhaps create a limited user to access it. I can find no examples of either.

Share Improve this question asked Feb 6, 2013 at 13:06 martinwnetmartinwnet 5812 gold badges4 silver badges10 bronze badges 1
  • 1 See embeddedanalytics. (I work with pany). We have a widget specifically for this (the Top Content widget). Allows you to have clickable links to those pages. Although it is currently served in an iframe - we could also enable to work via javascript (which would allow it to conform to your css). This service works with the API and is secure. – M Schenkel Commented Oct 14, 2014 at 20:47
Add a ment  | 

1 Answer 1

Reset to default 8

You can't access GA withouth authentication for rather the same reason you cannot access you bank account without authentication (because that would allow everybody else to access your account without authentication which might cause some inconvenience).

Google provides a plete example for GA access via Javascript: https://developers.google./analytics/solutions/articles/hello-analytics-api. However I don't think that's what you want (I think for that you need to be logged in to Google to actually retrieve data).

You could however use Google Apps Script to pull data into a Google Spreadsheet and embed that into your page (at least I think that should be safe).

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

本文标签: Accessing Google Analytics API data from javascript without authenticationStack Overflow