| @@ 57-76 (lines=20) @@ | ||
| 54 | }); |
|
| 55 | } |
|
| 56 | ||
| 57 | public function fetchMostVisitedPages(Period $period, int $maxResults = 20) { |
|
| 58 | $response = $this->performQuery( |
|
| 59 | $period, |
|
| 60 | 'ga:pageviews', |
|
| 61 | [ |
|
| 62 | 'dimensions' => 'ga:pagePath,ga:pageTitle', |
|
| 63 | 'sort' => '-ga:pageviews', |
|
| 64 | 'max-results' => $maxResults, |
|
| 65 | ] |
|
| 66 | ); |
|
| 67 | ||
| 68 | return collect($response['rows'] ?: []) |
|
| 69 | ->map(function (array $pageRow) { |
|
| 70 | return [ |
|
| 71 | 'url' => $pageRow[0], |
|
| 72 | 'pageTitle' => $pageRow[1], |
|
| 73 | 'pageViews' => (int) $pageRow[2], |
|
| 74 | ]; |
|
| 75 | }); |
|
| 76 | } |
|
| 77 | ||
| 78 | public function fetchTopReferrers(Period $period, int $maxResults = 20) { |
|
| 79 | $response = $this->performQuery($period, |
|
| @@ 78-94 (lines=17) @@ | ||
| 75 | }); |
|
| 76 | } |
|
| 77 | ||
| 78 | public function fetchTopReferrers(Period $period, int $maxResults = 20) { |
|
| 79 | $response = $this->performQuery($period, |
|
| 80 | 'ga:pageviews', |
|
| 81 | [ |
|
| 82 | 'dimensions' => 'ga:fullReferrer', |
|
| 83 | 'sort' => '-ga:pageviews', |
|
| 84 | 'max-results' => $maxResults, |
|
| 85 | ] |
|
| 86 | ); |
|
| 87 | ||
| 88 | return collect(isset($response['rows']) ? $response['rows'] : [])->map(function (array $pageRow) { |
|
| 89 | return [ |
|
| 90 | 'url' => $pageRow[0], |
|
| 91 | 'pageViews' => (int) $pageRow[1], |
|
| 92 | ]; |
|
| 93 | }); |
|
| 94 | } |
|
| 95 | ||
| 96 | public function fetchTopBrowsers(Period $period, int $maxResults = 10) { |
|
| 97 | $response = $this->performQuery( |
|