1

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

md jakaria
  • 75
  • 1
  • 7
  • https://developers.google.com/analytics/devguides/reporting/data/v1/api-schema – dikesh Jun 20 '22 at 05:15
  • Have any API that will return those dimension and matrix? – md jakaria Jun 20 '22 at 05:33
  • 1
    Here is the [method](https://developers.google.com/analytics/devguides/reporting/data/v1/rest/v1beta/properties/getMetadata) in Data API. I would recommend you to go through both [Data API](https://developers.google.com/analytics/devguides/reporting/data/v1/rest) and [Admin API](https://developers.google.com/analytics/devguides/config/admin/v1/rest) for GA4 thoroughly. – dikesh Jun 20 '22 at 05:54
  • Thanks for response. Have any implemented code for it to you? – md jakaria Jun 20 '22 at 06:51

1 Answers1

1

Yes, finally It helped me---

  1. https://developers.google.com/analytics/devguides/reporting/metadata/v3/reference/metadata/columns/list
  2. https://sodocumentation.net/google-analytics-api/topic/7297/metadata-api

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
md jakaria
  • 75
  • 1
  • 7