Google Analytics Embed API authentication

空扰寡人 提交于 2019-11-30 18:04:16

问题


I'm looking at getting some stats out of Google Analytics using the Embed API to display on our site using javascript.

My question is:

Is it possible to display the stats without the user authenticating? I.e. I would like to make some traffic statistics available to anonymous users.

Thanks, Chris.


回答1:


This is definitely possible, but you'll have to get the access token yourself (server side, using whatever OAuth 2.0 flow you want).

Once you have a valid access token, you can pass it to the gapi.analytics.auth component and use the Embed API as normal.

Here's some documentation on that:
https://developers.google.com/analytics/devguides/reporting/embed/v1/component-reference#auth

UPDATE: (07/27/2015)

A demo of server-side authorization with the Embed API is now featured on the Google Analytics Demos & Tools site. You should look there to see a working example.



来源:https://stackoverflow.com/questions/26590159/google-analytics-embed-api-authentication

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!