标准数据报告在使用测量协议的 GA4 项目中不显示任何内容

问题描述

我最近开始将 GA4 与测量协议 api 一起使用。我有一个问题,无论我发送多少事件、自定义事件还是自动事件,它们都不会出现在标准报告中。

enter image description here

我在用户资源管理器中看到用户

enter image description here

我用来向 api 发送事件的 JS 代码

fetch(
  `https://www.google-analytics.com/mp/collect?measurement_id=${measurement_id}&api_secret=${api_secret}`,{
    method: 'POST',body: {
      client_id: clientId,user_id: userId,events: [
         {
           name: 'first_visit',params: {},},{
           name: 'session_start',{
           name: 'custom_event',],user_properties: {},)

我知道 GA 需要一段时间来汇总数据,但我等了 4 天,它仍然到处显示 0。

我错过了什么吗?也许我需要发送一个特定的事件,以便 GA4 聚合它?还是我在请求中缺少某种参数?也许我需要在项目本身中配置一些东西?

任何帮助将不胜感激。

解决方法

尝试使用 JSON 正文

https://developers.google.com/analytics/devguides/collection/protocol/ga4/sending-events?client_type=firebase https://developers.google.com/analytics/devguides/collection/protocol/ga4/reference/events#purchase

body: JSON.stringify({
    app_instance_id: 'app_instance_id',events: [{
      name: 'tutorial_begin',params: {},}]
  })