Ad
Spatie-laravel-analytics Package Ga:users Not Accurate
My query to fetch data from google analytics using spatie-laravel-analytics
$analyticsData = Analytics::performQuery(Period::days(30),
'ga:',
[
'metrics' => 'ga:users,ga:newUsers,ga:sessions,ga:sessionsPerUser,ga:pageviews,ga:pageviewsPerSession,ga:avgSessionDuration,ga:bounceRate',
'dimensions' => 'ga:pageTitle',
'start-date' => '2018-08-01',
'end-date' => '2018-08-31',
]);
When I tried to see what's the result inside this is what I got.
And when I compare it to my google analytics 6/8 is working properly
Is there anyone having this kind of issue? My problem is my ga:users
is not accurate from google analytics that's why my ga:sessionPerUser
is giving me a incorrect value as well. Do you have any idea how to fix this? Thank you in advance.
Ad
Answer
In your laravel code, you are calling a period of days(30), while in your date range, it is actually 31 days, this might be the cause.
Use this for creating the period that you want and pass it in and remove the start-end dates from your query.
$startDate = Carbon::now()->subYear();
$endDate = Carbon::now();
Period::create($startDate, $endDate);
Ad
source: stackoverflow.com
Related Questions
- → "failed to open stream" error when executing "migrate:make"
- → October CMS Plugin Routes.php not registering
- → OctoberCMS Migrate Table
- → OctoberCMS Rain User plugin not working or redirecting
- → October CMS Custom Mail Layout
- → October CMS - How to correctly route
- → October CMS create a multi select Form field
- → October CMS - Conditionally Load a Different Page
- → How to disable assets combining on development in OctoberCMS
- → October CMS - Radio Button Ajax Click Twice in a Row Causes Content to disappear
- → OctoberCms component: How to display all ID(items) instead of sorting only one ID?
- → In OctoberCMS how do you find the hint path?
- → How to register middlewares in OctoberCMS plugin?
Ad