public function getVisitorsAndPageViewsForPeriod($startDate, $endDate, $groupBy = 'date')
    {
        $visitorData = [];
        $answer = $this->performQuery($startDate, $endDate, 'ga:visits,ga:pageviews', ['dimensions' => 'ga:'.$groupBy]);

        foreach ($answer->rows as $dateRow) {
            $visitorData[] = [$groupBy => Carbon::createFromFormat(($groupBy == 'yearMonth' ? 'Ym' : 'Ymd'), $dateRow[0]), 'visitors' => $dateRow[1], 'pageViews' => $dateRow[2]];
        }

        return new Collection($visitorData);
    }
public function getVisitorsAndPageViewsForPeriod($startDate, $endDate, $groupBy = 'date')
    {
        $visitorData = [];
        $answer = $this->performQuery($startDate, $endDate, 'ga:visits,ga:pageviews', ['dimensions' => 'ga:'.$groupBy]);

        foreach ($answer->rows as $dateRow) {
            $visitorData[] = [$groupBy => Carbon::createFromFormat(($groupBy == 'yearMonth' ? 'Ym' : 'Ymd'), $dateRow[0]), 'visitors' => $dateRow[1], 'pageViews' => $dateRow[2]];
        }

        return new Collection($visitorData);
    }
public function getVisitorsAndPageViewsForPeriod ( $ startDate , $ endDate , $ groupBy = 'date' ) { $ visitorData = [ ] ; $ answer = $ this -> performQuery ( $ startDate , $ endDate , 'ga:visits,ga:pageviews' , [ 'dimensions' => 'ga:' . $ groupBy ] ) ; foreach ( $ answer -> rows as $ dateRow ) { $ visitorData [ ] = [ $ groupBy => Carbon :: createFromFormat ( ( $ groupBy == 'yearMonth' ? 'Ym' : 'Ymd' ) , $ dateRow [ 0 ] ) , 'visitors' => $ dateRow [ 1 ] , 'pageViews' => $ dateRow [ 2 ] ] ; } return new Collection ( $ visitorData ) ; }
Get the amount of visitors and pageviews for the given period.

@param \DateTime $startDate
@param \DateTime $endDate
@param string    $groupBy   Possible values: date, yearMonth

@return Collection
Get the amount of visitors and pageviews for the given period .