1

I've followed the google analytics tutorial and created a PHP file with and added service key. But now I get this error:

User does not have any Google Analytics account

For the website where I'm given the access to view the traffic data for, I'm not given access to add new user. But my email(gmail) already added to their google analytics and I have access.

I did research online and came across this: Analytics Google API Error 403: “User does not have any Google Analytics Account”

Here They ask to add the email created upon the service key generation into the google analytics platform. Since I don't have access to add new user I couldn't do this.

What is the correct way for me to read the data?

Linda Lawton - DaImTo
  • 106,405
  • 32
  • 180
  • 449
112233
  • 2,406
  • 3
  • 38
  • 88

2 Answers2

1

User does not have any Google Analytics account

Means exactly that. The user you are authenticating does not have access to any google analytics accounts. You need to remember that a service account is not you. A service account is like a dummy user. It has its on google drive account, Google calendar account and probably a bunch more.

Service accounts need to be pre approved this is why you dont get the normal pop up Oauth2 consent screen.

To do this you go to the google analtyics website under the admin section for the account you wish to access using the service account. At the account level take the service account email address and grant it access like you would any other user.

enter image description here

It will then have access to read from your Google analytics account.

Linda Lawton - DaImTo
  • 106,405
  • 32
  • 180
  • 449
0

Looks like you need access the analytics API but instead, you were just given access to the Google Analytics tool.

For you to use the google analytics api, you need to create a service account and ask your admin to add the service account to GA, just like how they added your account to GA.

detailed documentation

XTOTHEL
  • 5,098
  • 1
  • 9
  • 17