Reputation: 75
I was going to extract data from google analytics with Python and google analytics report api v4, in the middle I need the Google analytics Dimensions and matrix there for a specific purpose(so that I can give user to select for which dimensions and matrix he need data). Also the Google analytics Dimensions and matrix has some valid combinations too. So is there any available REST API or library for that to collect all the dimensions and matrix from google analytics? (Acknowledge: There exists Python library for Service account but there is no library for web with python). I am done with authentication part with auth2. Now I need those available dimensions and matrix for the next progress. References: 1.https://ga-dev-tools.web.app/dimensions-metrics-explorer/ 2.https://developers.google.com/analytics/devguides/reporting/core/v4
Upvotes: 1
Views: 614
Reputation: 75
Yes, finally It helped me---
sample code:
def get_objects(self):
report_type = 'ga'
access_token = 'XXXXXXXXXXXXXXXXXXXXXXXXXX'
data_api_url = f'https://www.googleapis.com/analytics/v3/metadata/{report_type}/columns?access_token={access_token}'
print("data api_____", data_api_url)
response_api = requests.get(data_api_url)
data = data_api_url.text
print("________RESPONSE__________", data)
parse_json = json.loads(data)
return parse_json
Upvotes: 1