简体   繁体   English

Google Analytics Data API (GA4) 如何使用runRealtimeReport function?

[英]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.

相关问题 从 Google Analytics 数据 API (GA4) 获取实时信息,例如 UsersBysource、EventCountByEventName 和 eventParamerts - Get realtime information from Google Analytics Data API (GA4) like UsersBysource, EventCountByEventName and eventParamerts 如何在 Google Analytics(分析)4 (GA4) 媒体资源中添加引荐排除项 - How to add referral exclusions in Google Analytics 4 (GA4) properties 如何将Google Analytics(分析)ga函数用作阻止呼叫? - How to use Google Analytics ga function as a blocking call? 如何为 GOOGLE ANALYTICS 4 设置 Google Opt Out Cookie - 不是通用的 - 新的 ga4 - How to set an Google Opt Out Cookie FOR GOOGLE ANALYTICS 4 - not universal one - the new ga4 如何在服务器上使用新的 Google Analytics (GA4) 设置自定义事件跟踪? - How to setup custom event tracking with new Google Analytics (GA4) on the server? 是否仍然可以在 Google Analytics 4 (GA4) 中匿名化用户的 IP? - Is it still possible to anonymize the user's IP in Google Analytics 4 (GA4)? 使用新的 Google Analytics 4 (GA4) 服务器端进行跟踪 - Tracking with the new Google Analytics 4 (GA4) server-side 如何在尚未加载的异步 Javascript 中使用函数? (作为 Google Analytics 的 ga 函数) - How to use a function within an asynchronous Javascript that has not loaded yet? (As a ga function from Google Analytics) 如何在没有 Google Tag Manager 的情况下以编程方式将事件发送到 GA4? - How to programatically send an event to GA4 without Google Tag Manager? 在 Google 跟踪代码管理器和 Google Analytics 4 (GA4) 中手动触发 page_view 的规范方法是什么? - What is the canonical way to manually fire page_view in Google Tag Manager and Google Analytics 4 (GA4)?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM