我想获取用户ID,该ID可在用户资源管理器报告google Analytics(分析)中找到。 我在下面的batchGet中使用ga:clientId获取用户ID列表 https://developers.google.com/analytics/devguides/reporting/core/v4/rest/v4/reports/batchGet
我能够获取客户端ID,但是在使用以下API尝试相同的ID时 https://developers.google.com/analytics/devguides/reporting/core/v4/rest/v4/userActivity/search#request-body
找不到返回的400错误。 即使我复制了在Google Analytics(分析)中的用户浏览器报告仪表板中可见的用户ID,它仍然会返回400错误(未找到)。 我在做错什么吗?
代码段
analytics = build('analyticsreporting','v4',credentials=credentials)
body={
"viewId": VIEW_ID,"user": {
"type": "USER_ID",# I have tried CLIENT_ID Also
"userId": user_id # For now I have copied the value directly from the user explorer from browser itself for testing.But it didn't worked
}
}
result=analytics.useractivity().search(body=body).execute()
响应
回溯(最近一次通话最后一次):文件“ ga_session_data.py”,行 192,在 ga.main()文件“ ga_session_data.py”,第178行,位于主目录中 result = analytics.useractivity()。search(body = body).execute()文件“ env / lib / python3.6 / site-packages / googleapiclient / _helpers.py”, 第130行,位于positional_wrapper中 返回包装的(* args,** kwargs)文件“ env / lib / python3.6 / site-packages / googleapiclient / http.py”, 执行中的第856行 引发HttpError(resp,content,uri = self.uri)googleapiclient.errors.HttpError:https://analyticsreporting.googleapis.com/v4/useractivity:search?alt=json 返回了“ CLIENT_ID:XXXXXXXX找不到。”