【问题标题】:obtaining raw user and session data获取原始用户和会话数据
【发布时间】:2021-08-07 07:16:24
【问题描述】:

所以我对使用 Google Analytics API 非常陌生。我已设法使请求生效:

{
  "dateRange": {
    "startDate": "2021-01-08",
    "endDate": "2021-05-05"
  },
  "activityTypes": [
    "GOAL"
  ],
  "user": {
    "type": "CLIENT_ID",
    "userId": "2147448080.1620199617"
  },
  "viewId": "1556XXX89"
}

这样我就可以取回一个 json 格式的文件,例如:

{
  "sessions": [
    {
      "sessionId": "1620199614",
      "deviceCategory": "mobile",
      "platform": "Android",
      "dataSource": "web",
      "activities": [
        {
          "activityTime": "2021-05-05T07:53:08.366983Z",
          "source": "(direct)",
          "medium": "(none)",
          "channelGrouping": "Direct",
          "campaign": "(not set)",
          "keyword": "(not set)",
          "hostname": "somewebsite.com",
          "landingPagePath": "/client/loginorcreate/login",
          "activityType": "GOAL",
          "customDimension": [
            {
              "index": 1
            },
            {
              "index": 2
            },
            {
              "index": 3,
              "value": "59147"
            }
          ],
          "goals": {
            "goals": [
              {
                "goalIndex": 1,
                "goalCompletions": "1",
                "goalCompletionLocation": "/order/registerorder/postregister.html",
                "goalPreviousStep1": "page-z",
                "goalPreviousStep2": "page-y",
                "goalPreviousStep3": "page-x",
                "goalName": "order"
              }
            ]
          }
        }
      ],
      "sessionDate": "2021-05-05"
    }
  ],
  "totalRows": 1,
  "sampleRate": 1
}

现在,理想情况下,我会得到不同格式的响应,更重要的是,我不必指定每个单独的客户端 ID。有没有我可以构建的请求格式,它会返回如下内容:

clientID1 | activityTime | sessionId | activities
clientID2 | activityTime | sessionId | activities
clientID3 | activityTime | sessionId | activities

谢谢!

【问题讨论】:

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


    【解决方案1】:

    谷歌分析 api 以您当前看到的 json 格式返回数据。如何格式化这些数据将取决于您,但是这必须由您在本地完成。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-04-04
      • 1970-01-01
      • 2021-06-09
      • 2017-05-16
      • 1970-01-01
      • 2016-07-03
      • 2016-07-10
      • 1970-01-01
      相关资源
      最近更新 更多