我正在尝试使用此处描述的快速入门代码制作报告,它运行良好,但是当我尝试添加自定义维度时,我得到以下错误
google.api_core.exceptions.InvalidArgument:400 字段 uid 不是有效维度。有关有效维度和指标的列表,请参阅https://developers.google.com/analytics/devguides/reporting/data/v1/api-schema
我可以在谷歌分析中心使用这个自定义维度制作报告,所以我不明白为什么我会收到这个错误,这是代码(自定义维度是 uid)
def sample_run_report(property_id):
"""Runs a simple report on a Google Analytics App+Web property."""
# Using a default constructor instructs the client to use the credentials
# specified in GOOGLE_APPLICATION_CREDENTIALS environment variable.
client = AlphaAnalyticsDataClient(credentials=credentials)
request = RunReportRequest(
entity=Entity(property_id=property_id),
dimensions=[Dimension(name='uid')],
metrics=[Metric(name='userEngagementDuration')],
date_ranges=[DateRange(start_date='2020-07-01',end_date='today')])
response = client.run_report(request)
print("Report result:")
for row in response.rows:
print(row.dimension_values[0].value, row.metric_values[0].value)
def main():
sample_run_report(xxxxxx)
if __name__ == '__main__':
main()
编辑:我能够使用 name="customUser:uid" 创建查询