1

Things Ive done so far:

  1. What I am trying: Setup simple example of google analytics
  2. I have already enable the Google Analytics API.
  3. I have already created a Service account keys. This my key name: My Project-fc5b5fd6b551.json
  4. I have already enable my Demo account for Google Analytics, ref: https://support.google.com/analytics/answer/6367342#access
  5. I have already composer require google/apiclient:^2.0
  6. I already have a view_id which is the demo account the Raw Data View

But somehow I am having this error:
Fatal error: Uncaught Google_Service_Exception: { "error": { "code": 403, "message": "User does not have any Google Analytics account.", "errors": [ { "message": "User does not have any Google Analytics account.", "domain": "global", "reason": "forbidden" } ], "status": "PERMISSION_DENIED" } } in /Applications/MAMP/htdocs/native_analytics/vendor/google/apiclient/src/Google/Http/REST.php:118 Stack trace: #0 /Applications/MAMP/htdocs/native_analytics/vendor/google/apiclient/src/Google/Http/REST.php(94): Google_Http_REST::decodeHttpResponse(Object(GuzzleHttp\Psr7\Response), Object(GuzzleHttp\Psr7\Request), 'Google_Service_...') #1 /Applications/MAMP/htdocs/native_analytics/vendor/google/apiclient/src/Google/Task/Runner.php(176): Google_Http_REST::doExecute(Object(GuzzleHttp\Client), Object(GuzzleHttp\Psr7\Request), 'Google_Service_...') #2 /Applications/MAMP/htdocs/native_analytics/vendor/google/apiclient/src/Google/Http/REST.php(58): Google_Task_Runner->run() #3 / in /Applications/MAMP/htdocs/native_analytics/vendor/google/apiclient/src/Google/Http/REST.php on line 118

I did follow everything. I don't why I am having this error. Theory that I am thinking one is invalid service account key or wrong way of generating service account key, two, Demo account is not valid I think.

I am using Hello Analytics Reporting API v4; PHP quickstart for service accounts
Reference: https://developers.google.com/analytics/devguides/reporting/core/v4/quickstart/service-php#1_enable_the_api

KD.S.T.
  • 573
  • 1
  • 5
  • 27

0 Answers0