I\'m trying to fetch data with the Google Analytics API through service accounts.
I have been searching on stackoverflow how to do this and been using the exact sam
Had the same issue today, the profileId is hard to find, you can have it in every Url in analytics let's say https://www.google.com/analytics/web/#management/Settings/aXXXXXXwYYYYYYYpZZZZZZZ/ it's the ZZZZZZZ part
Same issue. Solved it by using the VIEW id instead of the account Id (UA-XXXXX-1).
Analytics Console > Admin -> View (Profile) -> View Settings -> View ID
AND
Make sure that you add the service account to your list of users in the Google Analytics Console. Simply setting it up in the Credentials, API and Permissions section of the developer console will still not grant it access to your analytics.
Analytics Console > Admin -> Account -> User Management -> "Add permissions for:"
Use View ID Not account ID, on Admin tab, 'View Settings' 'View ID'.
Helped me a lot after 2 weeks of trying to find solution:
Analytics Console -> Admin -> View (Profile) -> View Settings -> View ID
On a different application I was getting "Not sufficient permissions" and found my .htaccess file had some file restrictions that caused the problem.
Had the problem.. it turns out the Account ID is hidden in the URL of your analytics account!
https://developers.google.com/analytics/devguides/reporting/core/v3/#user_reports
The URL typically looks like so:
https://www.google.com/analytics/web/?hl=en#management/Settings/a51343283w84330433p87396224/%3Fm.page%3DAccountSettings/
The ID we are looking for follows the letter p.
In the example above, the ID that will work is: 87396224