访问Google Analytics Realtime Reporting API(通过javascript)是否与Core Reporting API类似地处理,还是截然不同?

时间:2022-01-20 15:21:49

I'm using the 'Hello Analytics' code example found at [https://developers.google.com/analytics/devguides/reporting/core/v3/quickstart/web-js][1] to allow me to gain access to my Google Analytics account and log the JSON response to the console. I can traverse the JSON and see how to request specific data I want from the Core Reporting API... Its pretty awesome.

我正在使用[https://developers.google.com/analytics/devguides/reporting/core/v3/quickstart/web-js] [1]中的“Hello Analytics”代码示例,以便我可以访问我的Google Analytics帐户并将JSON响应记录到控制台。我可以遍历JSON,看看如何从Core Reporting API请求我想要的特定数据...它非常棒。

I'm more interested in the realtime data, however. For this particular project I need something faster than the core reporting API...

但是,我对实时数据更感兴趣。对于这个特定的项目,我需要比核心报告API更快的东西......

Questions: Is the Realtime Reporting API something that is accessible via javascript and if so, would it (generally speaking) also work in this same fashion? Meaning Is it just a matter of changing EITHER of the following to get the same type of response from the REALTIME api?

问题:Realtime Reporting API是否可通过javascript访问,如果是这样,它(通常来说)是否也以同样的方式工作?含义是否只需更改以下内容即可从REALTIME API获取相同类型的响应?

// Set authorized scope.
var SCOPES = ['https://www.googleapis.com/auth/analytics.readonly'];

or

要么

// Load the Google Analytics client library.
gapi.client.load('analytics', 'v3').then(function() {

I see a good number of resources / examples for the core reporting API, but not much on the realtime API

我看到了核心报告API的大量资源/示例,但实时API并不多

1 个解决方案

#1


2  

The Core Reporting API and the Real time API work very much the same way, with the same authentication scopes even.

Core Reporting API和Real time API的工作方式非常相似,甚至具有相同的身份验证范围。

Core Reporting API call

gapi.client.analytics.data.ga.get(...)

Core Reporting API method reference.

核心报告API方法参考。

Real time API call

gapi.client.analytics.data.realtime.get(...)

Realtime API method reference.

实时API方法参考。

The Realtime API has is its own set of dimensions and metrics that begin with rt:... where the Core reporting API dimensions and metrics begin with ga:....

Realtime API有自己的一组维度和指标,以rt:...开头,其中Core报告API维度和指标以ga开头:....

#1


2  

The Core Reporting API and the Real time API work very much the same way, with the same authentication scopes even.

Core Reporting API和Real time API的工作方式非常相似,甚至具有相同的身份验证范围。

Core Reporting API call

gapi.client.analytics.data.ga.get(...)

Core Reporting API method reference.

核心报告API方法参考。

Real time API call

gapi.client.analytics.data.realtime.get(...)

Realtime API method reference.

实时API方法参考。

The Realtime API has is its own set of dimensions and metrics that begin with rt:... where the Core reporting API dimensions and metrics begin with ga:....

Realtime API有自己的一组维度和指标,以rt:...开头,其中Core报告API维度和指标以ga开头:....