尝试使用 Universal Analytics 版本 4 运行这段代码后,我遇到了错误: 代码:
def get_ua_report(analytics):
"""Fetches the report data from Google Analytics UA."""
return analytics.reports().batchGet(
body={
'reportRequests': [
{
'viewId': VIEW_ID,
'dateRanges': [{'startDate': config['UA_INITIAL_FETCH_FROM_DATE'], 'endDate': config['UA_FETCH_TO_DATE']}],
'metrics': [{'expression': 'ga:users'}],
'dimensions': [{'name': 'ga:date'}, {'name': 'ga:acquisitionSource'},{'name': 'ga:acquisitionCampaign'},{'name': 'ga:acquisitionMedium'},],
'pageSize': 10000
}
]
}
).execute()
发生错误:
https://analyticsreporting.googleapis.com/v4/reports:batchGet?alt=json 返回“无法查询所选维度和指标 一起。”。详细信息:“所选维度和指标不能 一起查询。">
我检查了所有文档并使用了Google的工具(https://ga-dev-tools.google/dimensions-metrics-explorer/)。它确认了指标和维度是兼容的。谁能帮我解决这个问题吗?
解决方案是选择不同的维度和指标。
它们不兼容的原因是数据不存在,所以你不能一起查询它们