Reputation:
I use spatie laravel google analytics with no error but when I use:
$analyticsData = Analytics::performQuery($per,'ga:sessions',$dimen);
I get this error:
htmlspecialchars() expects parameter 1 to be string, object given
All my code is:
$startDate = Carbon::now()->subYear();
$endDate = Carbon::now();
$per=Period::create($startDate, $endDate);
$dimen=['dimensions' => 'ga:browser'];
$analyticsData = Analytics::performQuery($per,'ga:sessions',$dimen);
Upvotes: 0
Views: 1376
Reputation: 344
You can try like this, just you have to change your metrics and dimensions as per your requirement.
$days = 30;
$users = Analytics::performQuery(Period::days($days),'ga:users',['dimensions'=>'ga:campaign,ga:source,ga:medium']);
Upvotes: 3
Reputation: 2474
You need to specify last perimeter as an array
Analytics::performQuery($period,'ga:sessions',['dimensions' => $dimen]);
Upvotes: 1