【问题标题】:Why is direct traffic not being returned from google analytics api?为什么没有从谷歌分析 api 返回直接流量?
【发布时间】:2022-01-08 13:22:34
【问题描述】:

我正在编写一个应用程序,使用 Google.Apis.AnalyticsReporting.v4 从 .NET core 3.5 中的 Google Analytics 下载数据。 由于某种原因,直接流量(sourceMedium 为 (direct) / (none) 的行)未从 GA 返回。未应用过滤器,日期范围始终为一天。 玩弄它,我发现添加时间维度 dateHour 可以解决问题。但它显着增加了行数,我真的想避免这种情况。

知道为什么这个请求会成功返回所有记录:

         ReportRequest reportRequest = new ReportRequest
            {
                ViewId = viewId,
                //IncludeEmptyRows = true,
                DateRanges = new List<DateRange>() { dateRange },
                Metrics = new List<Metric>() { sessions, transactions, transactionRevenue },
                Dimensions = new List<Dimension>() { date, sourceMedium, campaign, datehour },
                //DimensionFilterClauses = new List<DimensionFilterClause>() { dimFilters },
                PageSize = 10000,
                PageToken = "1"
            };

但是当删除 datehour 维度时,响应中缺少直接流量(并且只有直接流量)?

            ReportRequest reportRequest = new ReportRequest
            {
                ViewId = viewId,
                //IncludeEmptyRows = true,
                DateRanges = new List<DateRange>() { dateRange },
                Metrics = new List<Metric>() { sessions, transactions, transactionRevenue },
                Dimensions = new List<Dimension>() { date, sourceMedium, campaign },
                //DimensionFilterClauses = new List<DimensionFilterClause>() { dimFilters },
                PageSize = 10000,
                PageToken = "1"
            };

IncludeEmptyRows 参数对结果没有任何影响。 欢迎提出任何建议。

【问题讨论】:

    标签: c# .net-core google-analytics google-analytics-4


    【解决方案1】:

    我的解决方案是更改日期范围。当 StartDate 和 EndDate 是同一天时,所有流量都将返回,直接流量除外。当 StartDate 和 EndDate 不是同一天时,所有流量都会返回。

    【讨论】:

      猜你喜欢
      • 2014-09-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-10-13
      • 1970-01-01
      相关资源
      最近更新 更多