javascript - Google Analytics Reporting API v3 requires user to be logged in -


i attempting fetch our website's unique user's data google analytics , display data along side other data in custom graph. have set , working long logged google. if not logged in (or user without permissions) hits page fails.

goal: want able query analytics api unique users.

here's snippet of code failing due error states "login required".

gapi.client.analytics.data.ga.get({   'ids': 'ga:' + profileid,   'dimensions': 'ga:date',   'start-date': '30daysago',   'end-date': 'yesterday',   'metrics': 'ga:sessions', }).execute(function (results, resultsjsonstringified) {   // stuff... }); 

to access google analytics api , of google apis must authenticated. authenticating using oauth2 requested access google analytics data. if else ran script access google analytics data not data site.

in instace want show own data recommend using service account. using service account give account access google analytics data , load no user interaction needed.

the problem going have can't use service account javascript. need use server sided scripting language. recommend cache information. there no reason run request more once day. set run @ night save information database or display users then.


Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -