more function on spatie/google analytics packages this is the first time I used spatie/google analytics packages to get website visitors
https://github.com/spatie/laravel-analytics
its provide some function, but I want more than that
like:
1- total active now and visited pages.
2- country and number of user fore each country.
any help
@sinnbeck
for example
$analyticsData = Analytics::performQuery(
Period::years(1),
'ga:sessions',
[
'metrics' => 'ga:sessions, ga:pageviews',
'dimensions' => 'ga:yearMonth'
]
);
return $analyticsData;
but i got error
@sinnbeck
TypeError
Argument 1 passed to Symfony\Component\HttpFoundation\Response::setContent() must be of the type string or null, object given, called in /home4/panorax1/lcode/vendor/laravel/framework/src/Illuminate/Http/Response.php on line 65
to getTopOs For Example
public function fetchTopOs(Period $period, int $maxResults = 10): Collection
{
$response = $this->performQuery(
$period,
'ga:sessions',
[
'dimensions' => 'ga:operatingSystem',
'sort' => '-ga:sessions',
]
);
$topOs = collect($response['rows'] ?? [])->map(function (array $osRow) {
return [
'operatingSystem' => $osRow[0],
'sessions' => (int) $osRow[1],
];
});
if ($topOs->count() <= $maxResults) {
return $topOs;
}
return $this->summarizeTopOS($topOs, $maxResults);
}
Please sign in or create an account to participate in this conversation.