简体   繁体   English

某些维度导致 GA4 runReport API 的响应为空

[英]Some Dimensions Cause Empty Response for GA4 runReport API

I believe this is a regression and used to work, but when I make queries against the GA4 RunReport API and request data which includes the dimensions "source", "medium" or "defaultChannelGrouping" I get a 200 from the server with no rows.我相信这是一种回归并且曾经可以工作,但是当我对 GA4 RunReport API 进行查询并请求包含维度“源”、“中”或“defaultChannelGrouping”的数据时,我从服务器获得了 200,没有行。

For Example:例如:

const dimensions = ['browser', 'source'];
const basicDataMetrics = ['sessions'];
const body = {
            dimensions: dimensions.map((z) => { return { name: z } }),
            metrics: metrics.map((z) => { return { name: z } }),
            dateRanges: [
                {
                    endDate: dateToQuery,
                    startDate: dateToQuery
                },
            ],
            offset: startIndex,
            limit: maxResults,
            keepEmptyRows: true,
            returnPropertyQuota: true
        }
const ga4Response = await axios.post(`https://analyticsdata.googleapis.com/v1beta/properties/${webPropertyId}:runReport`, body, { headers });

In the above example, gaResponse.data will have something like在上面的示例中, gaResponse.data 将具有类似

{
  dimensionHeaders: [
    {
      name: "browser",
    },
    {
      name: "source",
    },
  ],
  metricHeaders: [
    {
      name: "sessions",
      type: "TYPE_INTEGER",
    },
  ],
  metadata: {
    currencyCode: "EUR",
    timeZone: "Europe/Paris",
  },
  kind: "analyticsData#runReport",
}

Notice the completely missing rows or rowCount.注意完全丢失的行或行数。 If I omit 'source' from my dimensions everything works as expected.如果我从我的尺寸中省略“来源”,一切都会按预期工作。 I've noticed that 'medium' and 'defaultChannelGrouping' also cause this behavior.我注意到 'medium' 和 'defaultChannelGrouping' 也会导致这种行为。 All of these dimensions used to be valid and are still valid accoring to the documentation . 根据文档,所有这些维度过去都是有效的并且仍然有效。 Does anyone know what I can do to get results for these dimensions?有谁知道我可以做些什么来获得这些维度的结果? Are they deprecated for this API?这些 API 是否已弃用?

If your GA4 property's Reporting Attribution model is neither Cross-channel last click nor Ads-preferred last click, then event-scoped attribution dimensions like "source", "medium", and "defaultChannelGrouping" return data for only conversion events.如果您的 GA4 媒体资源的报告归因模型既不是跨渠道最终点击也不是广告首选的最终点击,则事件范围的归因维度(如“来源”、“媒介”和“defaultChannelGrouping”)仅返回转化事件的数据。 Attribution models are explained some on About attribution and attribution modeling .归因模型在About attribution and attribution modeling中有一些解释。

Try using "sessionSource", "sessionMedium", or "sessionDefaultChannelGrouping" in your request.尝试在您的请求中使用“sessionSource”、“sessionMedium”或“sessionDefaultChannelGrouping”。 If you use "sessionSource", your example request will return rows if at least one session occured on your GA4 property in the date range.如果您使用“sessionSource”,那么如果您的 GA4 媒体资源在日期范围内至少发生了一次会话,那么您的示例请求将返回行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM