|
@@ -78,15 +78,11 @@ class IndexController extends Controller
|
|
|
'productCheckouts'=>"ga:productCheckouts",
|
|
|
];
|
|
|
$i=1;
|
|
|
- $list=[];
|
|
|
- foreach($metrics as $metric){
|
|
|
- $lis[]=$metric;
|
|
|
- if($i%10==0||count($metrics)==$i){
|
|
|
- $response = $this->getReport($analytics,$list);
|
|
|
+ $datas=array_chunk($metrics,10);
|
|
|
+ foreach($datas as $data){
|
|
|
+ $response = $this->getReport($analytics,$data);
|
|
|
$this->printResults($response);
|
|
|
$list=[];
|
|
|
- }
|
|
|
- $i++;
|
|
|
}
|
|
|
exit;
|
|
|
return $this->render('index');
|
|
@@ -116,7 +112,7 @@ class IndexController extends Controller
|
|
|
* @param service An authorized Analytics Reporting API V4 service object.
|
|
|
* @return The Analytics Reporting API V4 response.
|
|
|
*/
|
|
|
-function getReport($analytics,$arr) {
|
|
|
+function getReport($analytics,$data) {
|
|
|
$VIEW_ID = "155703065";
|
|
|
// Create the DateRange object.
|
|
|
$dateRange = new \Google_Service_AnalyticsReporting_DateRange();
|
|
@@ -125,7 +121,7 @@ function getReport($analytics,$arr) {
|
|
|
$metrics=[];
|
|
|
$dimensions=[];
|
|
|
|
|
|
- foreach($arr as $k=>$v){
|
|
|
+ foreach($data as $k=>$v){
|
|
|
$Metric = new \Google_Service_AnalyticsReporting_Metric();
|
|
|
$Metric->setExpression($v);
|
|
|
$Metric->setAlias($k);
|