[英]Google Analytics Data API (GA4) How to use runRealtimeReport function?
I do a call to我打电话给
await analyticsDataClient.runRealtimeReport({
entity: {
propertyId: propertyId,
},
dateRanges: [
{
startDate: '2020-03-31',
endDate: 'today',
},
],
dimensions: [
{
name: 'city',
},
],
metrics: [
{
name: 'activeUsers',
},
],
});
but this return the following error:但这会返回以下错误:
A property in the form 'properties/1234' where '1234' is a GA4 property Id is required
I think it is because my object inside my runRealtimeReport
function is wrong but I don't know how to put in.我认为这是因为我的 runRealtimeReport runRealtimeReport
中的 object 是错误的,但我不知道如何放入。
To create a realtime report, you need to update the request to be similar to要创建实时报告,您需要将请求更新为类似于
const propertyId = 'YOUR-GA4-PROPERTY-ID';
const [response] = await client.runRealtimeReport({
property: 'properties/' + propertyId,
dimensions: [{ name: 'city', },],
metrics: [{ name: 'activeUsers', },],
});
Please replace the 'YOUR-GA4-PROPERTY-ID' with your numeric property ID.请将“YOUR-GA4-PROPERTY-ID”替换为您的数字资产 ID。 This page describes where to find your GA4 property ID. 本页介绍了在哪里可以找到您的 GA4 媒体资源 ID。
Realtime reports do not need dateRanges.实时报告不需要 dateRanges。 Realtime reports are always for the last 30 minutes for your App or Website.您的应用程序或网站的实时报告始终为最后 30 分钟。 There is more information about creating realtime reports on this page .在此页面上有更多关于创建实时报告的信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.