Hello everyone,
I'm encountering an issue with fetching data from Google Analytics to a custom-built dashboard using the Laravel package spatie/laravel-analytics. Despite following the documentation and ensuring the service account has the appropriate permissions, I receive an "insufficient permissions" error.
Steps Taken:
Configuration Summary:
Error Encountered:
Google\Service\Exception
{
"error": {
"code": 403,
"message": "User does not have sufficient permissions for this profile.",
"errors": [
{
"message": "User does not have sufficient permissions for this profile.",
"domain": "global",
"reason": "insufficientPermissions"
}
]
}
}
analytics.php Configuration:
<?php
return [
'view_id' => env('ANALYTICS_VIEW_ID'),
'service_account_credentials_json' => storage_path('***/***/forexef-815937d2e889.json'),
'cache_lifetime_in_minutes' => 60 * 24,
'cache' => [
'store' => 'file',
],
];
Test Request:
<?php
namespace App\Http\Controllers\backend;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Spatie\Analytics\AnalyticsFacade as Analytics;
use Spatie\Analytics\Period;
class AnalyticsController extends Controller
{
public function index()
{
$analyticsData = Analytics::fetchMostVisitedPages(Period::days(30));
dd($analyticsData);
return view('backend.pages.home', compact('analyticsData'));
}
}
Despite following these steps, I am still receiving the "User does not have sufficient permissions for this profile" error. Any guidance or suggestions on resolving this issue would be greatly appreciated.
Thank you!
Hello,
Thank you for contacting the Google Cloud Community.
The error "User does not have sufficient permissions for this profile" indicates a discrepancy between the service account's permissions and the Google Analytics property you're trying to access.
Regards,
Jai Ade
hello @jaia thank you responding i have created a new service account and linked it to google analytics assigned to it editor role
and then i installed google/apiclient following your suggestion to use Analytics Data API without laravel package
but i'm still getting this error
Hello,
Thank you for contacting the Google Cloud Community.
I have gone through your reported issue, however it seems like this would need more specific debugging and analysis. To ensure a faster resolution and dedicated support for your issue, I kindly request you to file a support ticket by clicking here. Our support team will prioritize your request and provide you with the assistance you need.
For individual support issues, it is best to utilize the support ticketing system. We appreciate your cooperation!