简体   繁体   中英

Google Analytics API JavaScript show data without login to users on dashboard

I am using Google Analytics API, I have setup everything in the settings on GOOGLE account, I can fetch the values properly on pentaho dashboard successfully, but issue is that when I use any other email account to login and view the page, it says authentication issue, I have used both Immediate as True and False , but nothing works, All I want is that anyone who can view the Pentaho Dashboard can view the analytic data.

Note: I am using JavaScript API.

I have also passed Immediate as True on First call, then made second call to authorize function using False in response, but nothing is working for me.

I also get User does not have any Google Analytic Account. I want it to be open for everyone...

The Javascript API requires that the user is logged in to Google and has access to your Google Analytics account. There's no way around it as far as I know.

What you want to do is use some kind of server side code to fetch data with your credentials or a service account and store the data you want in your database. Then you need to write a frontend that fetches data from the database and show to your users.

Thankfully google has a project that makes the whole process for you it's called Google Analytics super cache . It's an appengine app that does the fetching of data and storing and make it easier to query the data to show to your not-logged-in users.

https://developers.google.com/analytics/solutions/google-analytics-super-proxy

Unfortunately, in case of JS to access without logging in, it would require some other kind of access like private API code, and since JS is client side, it would appear to the public.

Hence in JS the only form is to access by logging in.

On the other hand, Server side codes, like PHP would enable you to access the data with just the API code, no login is necessary.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM