I am trying to pull Google analytics data using python google-api-client. But I need to mention the list of dimensions and metrics in the body of the request 'dimensions':[{'name' : 'ga:date'}]. But is there any way to get the full list of dimensions and metrics associated with a view ID. Can i get that list by API call?
sample_request = {
'viewId': 'xxxxxx',
'dateRanges': [{'startDate': '7daysAgo', 'endDate': 'today'}],
'metrics' : [{'expression' : 'ga:users'}],
'dimensions':[{'name' : 'ga:date'}]
}
response = api_client.reports().batchGet(
body={
'reportRequests': sample_request
}).execute()
Here you can find the list of all the metrics and dimensions that can be queried for any view in Analytics: https://ga-dev-tools.appspot.com/dimensions-metrics-explorer/