问题
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);
回答1:
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']);
回答2:
You need to specify last perimeter as an array
Analytics::performQuery($period,'ga:sessions',['dimensions' => $dimen]);
来源:https://stackoverflow.com/questions/44739481/spatie-laravel-analytics-performquery-error