I want to acquire and automate the data seen in the GA view using an API! So I tried it.
Create a project on GCP

Enter a project name and click Create.

Selecting the API to use
Go to the dashboard screen of the project you created and select "APIs and Services" → "Libraries"

Search for Google Analytics etc. and select "Google Analytics Reporting API".

Select "Enable".

Creating authentication information (service account)
You will be redirected to the API settings screen, so click “Create Credentials”

Let's set each setting value according to the purpose.

Enter a suitable name for the service account and proceed.

You can omit the rest and complete. (If you know, set it later)

Create private key
Create a private key to access the API. From the service account you created earlier, select "Key" → "Create new key"

You will be using JSON, so select it and create it.

The private key will be downloaded to your download folder.

Granting view privileges to service account (email address)
From the View Management screen, select Manage View Users.

Add the created service account as a user.

Enter the email address of the service account you created and grant viewing and analysis permissions.

Permissions are now granted.
Next time, I would like to actually use PHP to access this API!



comment