谷歌分析嵌入 API 身份验证 [英] Google Analytics Embed API authentication

查看:29
本文介绍了谷歌分析嵌入 API 身份验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在考虑使用 Embed API 从 Google Analytics 中获取一些统计信息,以便使用 javascript 显示在我们的网站上.

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

我的问题是:

是否可以在没有用户身份验证的情况下显示统计信息?IE.我想向匿名用户提供一些流量统计信息.

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.

谢谢,克里斯.

推荐答案

这绝对是可能的,但是您必须自己获取访问令牌(服务器端,使用任何 OAuth 2.0 流程 你想要).

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

拥有有效的访问令牌后,您可以将其传递给 gapi.analytics.auth 组件并照常使用 Embed API.

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

这里有一些关于此的文档:
https://developers.google.com/analytics/devguides/reporting/embed/v1/component-reference#auth

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

使用 Embed API 进行服务器端授权的演示 现在出现在 Google Analytics Demos &工具网站.您应该在那里查看工作示例.

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.

这篇关于谷歌分析嵌入 API 身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆