gpt4 book ai didi

google-analytics - 现在的活跃用户(Reporting API v4)

转载 作者:行者123 更新时间:2023-12-03 16:07:58 25 4
gpt4 key购买 nike

我正在努力通过 JavaScript 从 Reporting API v4 获取当前活跃的用户。我发现这部分文档正在处理它,它在哪里可以作为“rt:activeUsers”使用,但它适用于 v3,而不是 v4 - https://developers.google.com/analytics/devguides/reporting/realtime/dimsmets/ . v4 的文档中似乎没有这样的选项 - https://developers.google.com/analytics/devguides/reporting/core/dimsmets#cats=user

我是不是忽略了什么?请参阅下面的代码

 <!-- API CALL -->
<script>

// VIEW ID
var view_id = '0000000';
var start_date = '7daysAgo';
var end_date = 'today';

// LOAD DATA FROM GOOGLE ANALYTICS
function loadAnalytics() {
gapi.client.request({

// CONFIGURATION
path: '/v4/reports:batchGet',
root: 'https://analyticsreporting.googleapis.com/',
method: 'POST',

// REQUEST
body: {
reportRequests: [{

// VIEW ID
viewId: view_id,

// DATA RANGE FOR RESULTS
dateRanges: [{
startDate: start_date,
endDate: end_date
}],

dimensions: [

{ name:"ga:browser" },
{ name:"ga:browserVersion" },
{ name: "ga:userType"}

],

// REQUESTED DATA
metrics: [

{ expression: 'ga:hits' },
{ expression: 'ga:users' },
{ expression: 'ga:newUsers' },
{ expression: 'ga:sessions' },
{ expression: 'ga:avgSessionDuration' },
{ expression: 'ga:percentNewSessions' },
{ expression: 'ga:sessionsPerUser'},
{ expression: 'ga:bounces' },
{ expression: 'ga:bounceRate' },
{ expression: 'ga:activeUsers'}

]

}]
}

// PUSH OBTAINED DATA TO DISPLAYING FUNCTION
}).then(prepareVariables, console.error.bind(console));
}

最佳答案

Reporting API V4

The most advanced method to programmatically access report data in Google Analytics. Build pivot tables as well as cohort, lifetime value, and advanced segmentation reports with the most flexible access to your data.


Google Analytics reporting v4 api可用于从 Google 分析请求数据。这不是实时数据。此 ID 数据在处理后立即出现在谷歌分析网站中。数据出现在此 API 中可能需要几个小时(此数据可能未激活)到几天的时间。
这是由于数据延迟 doc

Processing latency is 24-48 hours. Standard accounts that send more than 200,000 sessions per day to Analytics will result in the reports being refreshed only once a day. This can delay updates to reports and metrics for up to two days. To restore intra-day processing, reduce the number of sessions your account sends to < 200,000 per day.


Realtime API V3

Get user activity occurring on a property right now. Realtime reports are updated within seconds so you can build live dashboards to monitor how users are interacting with your property at any moment.


实时 API 非常基础。并非所有数据都在那里。但它是你应该使用的这个 api
谷歌分析 API
这是对以下评论的回应。谷歌分析 API 分为几个 API。
  • MetaData api 用于从谷歌分析返回维度和指标。
  • 管理api目前在V3用于管理 Google 分析帐户。
  • 核心报告 API。用于选择当前已完成处理的谷歌分析数据有v3v4 . (从技术上讲,v2 仍然有效,但我不建议使用它。)
  • 实时 api,用于请求实时谷歌分析数据,例如用户帐户当前有多少用户处于事件状态。只有v3这个api的。

  • 所以仅仅因为报告 api、管理 api 和实时 api 都有 v3 版本并不意味着它们是相同的。报告 api 没有实时数据,这不是实时 api 的用途。

    关于google-analytics - 现在的活跃用户(Reporting API v4),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51910689/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com