我喜欢获取用户资源管理器报告谷歌分析中可用的用户 ID。我正在使用下面的 batchGet 来使用 ga:clientId https://developers.google.com/analytics/devguides/reporting/core/v4/rest/v4/reports/batchGet获取用户 ID 列表
我能够获取客户端 ID,但是在使用以下 API https://developers.google.com/analytics/devguides/reporting/core/v4/rest/v4/userActivity/search#request-body尝试相同的 ID 时
未找到其返回的 400 错误。即使我复制了在谷歌分析的用户资源管理器报告仪表板中可见的用户 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 行,在主要结果中=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 行,在执行 raise HttpError(resp, content, uri=self.uri) googleapiclient.errors.HttpError: https://analyticsreporting.googleapis.com/v4/userActivity:search ?alt=json 返回“CLIENT_ID: XXXXXXXX 未找到。”>