def get_report(analytics):
return analytics.reports().batchGet(
body={
'reportRequests':
[
{
'viewId': VIEW_ID,
'dateRanges': [{'startDate': '7daysAgo', 'endDate': 'today'}],
'metrics': [{'expression':i} for i in METRICS],
'dimensions': [{'name':j} for j in DIMENSIONS]
}
]
}
).execute()
File "/home/mail_name/gaToPandas/lib/python3.5/site-packages/googleapiclient/http.py", line 851, in execute raise HttpError(resp, content, uri=self.uri) googleapiclient.errors.HttpError: https://analyticsreporting.googleapis.com/v4/reports:batchGet?alt=json returned "Invalid value '[email protected]' for viewId parameter.">
How can I resolve this issue? There is an error in step 3 of this site https://www.digishuffle.com/blogs/google-analytics-reporting-python/
"Invalid value '[email protected]' for viewId parameter."
The view Id should be the view id from Google Analytics which you wish to request data for not the service account name.