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);
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']);