Setting up Google Analytics4 API

You can use Google Analytics4 API to automate and extract data using code. If you already have a website and want to get intelligent insights, you may consider setting up the API. You can then make python scripts and dashboards to get easy and useful insights about your data.

Prerequisites :

  • Google developer profile :
  • A google analytics property setup.

Step1: Enable the api

Google Analytics4 Page

Click quickstart and write name of project. You may call it anything you like. We called it GATest

Google Analytics4 Page on clicking Quickstart

Agree to the terms and conditions and click next. You should be given a private key. Download it as json. Remember not to share this key publicly.

Google Analytics4 Page, secret key

Step 2: Add service account to the Google Analytics Property

Go to the secret key downloaded in the step above. In this case, it is named service_account.json. Search for client_email field to obtain the service account email address that looks similar to:

quickstart@PROJECT-ID.iam.gserviceaccount.com

Sign in to your google analytics 4. Go to the left panel and click on admin

Google Analytics4 add user to property

This should open your properties. Choose “Property Access Management” option for your desired property.this should give a list of user and the permissions allotted to them. Click on a blue ‘+’ button on the right

Google Analytics4, add user.

Add the client_email you copied here. Choose the permission you wish to allot. You can choose “editor” or “viewer” in this case.

This should set up your google analytics api for your particular property.

Step 3: Note your property id

Googe Analytics4 Property id

Leave a Comment

Your email address will not be published. Required fields are marked *