spatie/laravel-analytics performQuery error

喜欢而已 提交于 2019-12-25 09:25:39

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!