I am trying to make a report using the quickstart code described Here, it works perfectly, but when I try to add a custom dimension, I obtain the following Error
google.api_core.exceptions.InvalidArgument: 400 Field uid is not a valid dimension. For a list of valid dimensions and metrics, see https://developers.google.com/analytics/devguides/reporting/data/v1/api-schema
I am able to make reports using this custom dimension in google analytics hub, so I dont understand why I am getting this error, this is the code (the custom dimension is 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()
EDIT: I Was able to create the query using name="customUser:uid"