Google 分析数据API (GA4) 如何使用 runRealtimeReport 函数?
Google Analytics Data API (GA4) How to use runRealtimeReport function?
我打电话给
await analyticsDataClient.runRealtimeReport({
entity: {
propertyId: propertyId,
},
dateRanges: [
{
startDate: '2020-03-31',
endDate: 'today',
},
],
dimensions: [
{
name: 'city',
},
],
metrics: [
{
name: 'activeUsers',
},
],
});
但是这个return出现以下错误:
A property in the form 'properties/1234' where '1234' is a GA4 property Id is required
我想是因为我的 runRealtimeReport
函数里面的对象是错误的,但我不知道如何放入。
要创建实时报告,您需要将请求更新为类似于
const propertyId = 'YOUR-GA4-PROPERTY-ID';
const [response] = await client.runRealtimeReport({
property: 'properties/' + propertyId,
dimensions: [{ name: 'city', },],
metrics: [{ name: 'activeUsers', },],
});
请用您的数字 属性 ID 替换 'YOUR-GA4-PROPERTY-ID'。此 page 描述了在哪里可以找到您的 GA4 属性 ID。
实时报告不需要日期范围。实时报告始终针对您的应用程序或网站的最后 30 分钟。有关创建实时报告的更多信息 page。
我打电话给
await analyticsDataClient.runRealtimeReport({
entity: {
propertyId: propertyId,
},
dateRanges: [
{
startDate: '2020-03-31',
endDate: 'today',
},
],
dimensions: [
{
name: 'city',
},
],
metrics: [
{
name: 'activeUsers',
},
],
});
但是这个return出现以下错误:
A property in the form 'properties/1234' where '1234' is a GA4 property Id is required
我想是因为我的 runRealtimeReport
函数里面的对象是错误的,但我不知道如何放入。
要创建实时报告,您需要将请求更新为类似于
const propertyId = 'YOUR-GA4-PROPERTY-ID';
const [response] = await client.runRealtimeReport({
property: 'properties/' + propertyId,
dimensions: [{ name: 'city', },],
metrics: [{ name: 'activeUsers', },],
});
请用您的数字 属性 ID 替换 'YOUR-GA4-PROPERTY-ID'。此 page 描述了在哪里可以找到您的 GA4 属性 ID。
实时报告不需要日期范围。实时报告始终针对您的应用程序或网站的最后 30 分钟。有关创建实时报告的更多信息 page。