public function getMostVisitedPagesForPeriod($startDate, $endDate, $maxResults = 20)
    {
        $pagesData = [];

        $answer = $this->performQuery($startDate, $endDate, 'ga:pageviews', ['dimensions' => 'ga:pagePath', 'sort' => '-ga:pageviews', 'max-results' => $maxResults]);

        if (is_null($answer->rows)) {
            return new Collection([]);
        }

        foreach ($answer->rows as $pageRow) {
            $pagesData[] = ['url' => $pageRow[0], 'pageViews' => $pageRow[1]];
        }

        return new Collection($pagesData);
    }
public function getMostVisitedPagesForPeriod($startDate, $endDate, $maxResults = 20)
    {
        $pagesData = [];

        $answer = $this->performQuery($startDate, $endDate, 'ga:pageviews', ['dimensions' => 'ga:pagePath', 'sort' => '-ga:pageviews', 'max-results' => $maxResults]);

        if (is_null($answer->rows)) {
            return new Collection([]);
        }

        foreach ($answer->rows as $pageRow) {
            $pagesData[] = ['url' => $pageRow[0], 'pageViews' => $pageRow[1]];
        }

        return new Collection($pagesData);
    }
public function getMostVisitedPagesForPeriod ( $ startDate , $ endDate , $ maxResults = 20 ) { $ pagesData = [ ] ; $ answer = $ this -> performQuery ( $ startDate , $ endDate , 'ga:pageviews' , [ 'dimensions' => 'ga:pagePath' , 'sort' => '-ga:pageviews' , 'max-results' => $ maxResults ] ) ; if ( is_null ( $ answer -> rows ) ) { return new Collection ( [ ] ) ; } foreach ( $ answer -> rows as $ pageRow ) { $ pagesData [ ] = [ 'url' => $ pageRow [ 0 ] , 'pageViews' => $ pageRow [ 1 ] ] ; } return new Collection ( $ pagesData ) ; }
Get the most visited pages for the given period.

@param \DateTime $startDate
@param \DateTime $endDate
@param int       $maxResults

@return Collection
Get the most visited pages for the given period .