Google AnalyticsAPI v4会从API v3返回不同的结果

时间:2017-05-21 12:19:37

标签: google-analytics google-analytics-api google-analytics-v4 google-analytics-sdk

我过去2天试图解决这个问题 当我使用Google AnalyticsAPI V4时,我获得的结果比使用API​​ V3的结果要少。 我在两个版本中使用完全相同的参数。

API v4实施
Uri:https://analyticsreporting.googleapis.com/v4/reports:batchGet?access_token=_ACCESS_TOKEN_
方法:POST
身体:

{
  reportRequests: {
    viewId: "3829366",
    dateRanges: {
      startDate: "2017-05-19",
      endDate: "2017-05-19"
    },
    dimensions: [
      {
        name: "ga:dimension1"
      },
      {
        name: "ga:source"
      },
      {
        name: "ga:medium"
      },
      {
        name: "ga:campaign"
      },
      {
        name: "ga:channelGrouping"
      },
      {
        name: "ga:fullReferrer"
      },
      {
        name: "ga:adMatchedQuery"
      },
      {
        name: "ga:country"
      },
      {
        name: "ga:city"
      }
    ],
    metrics: [
      {
        expression: "ga:sessions"
      }
    ],
    filtersExpression: "ga:dimension1=~(598a56704f19aa39c5)|(674456acd5f2a5f1c2)|(9545632042f1223ced)|(24a1e3c96ba81890dc)|(7dd83f2d0321aae0d6)|(a68f93efad7d7574c8)",
    samplingLevel: "LARGE"
  }
}

从这个电话中我只得到1个结果。

API v3实施
Uri:https://www.googleapis.com/analytics/v3/data/ga
方法:GET
查询参数:

?ids=ga:3829366
&start-date=2017-05-19
&end-date=2017-05-19
&metrics=ga:sessions
&dimensions=ga:dimension1,ga:source,ga:medium,ga:campaign,ga:channelGrouping,ga:fullReferrer,ga:adMatchedQuery
&filters=ga:dimension1=~(598a56704f19aa39c5)|(674456acd5f2a5f1c2)|(9545632042f1223ced)|(24a1e3c96ba81890dc)|(7dd83f2d0321aae0d6)|(a68f93efad7d7574c8)
&samplingLevel=higher_precision
&access_token=_ACCESS_TOKEN_

通过此次通话,我获得了6个结果,正确的结果

如果有任何帮助,我将非常感激! 谢谢!

1 个答案:

答案 0 :(得分:0)

您是否在GA API资源管理器中尝试了这两个查询?我唯一能想到的是一些抽样问题。