| @@ 155-182 (lines=28) @@ | ||
| 152 | * @param int $maxResults |
|
| 153 | * @return array |
|
| 154 | */ |
|
| 155 | public function getTopReferrersForPeriod(DateTime $startDate, DateTime $endDate, $maxResults) |
|
| 156 | { |
|
| 157 | $answer = $this->performQuery( |
|
| 158 | $startDate, |
|
| 159 | $endDate, |
|
| 160 | 'ga:pageviews', |
|
| 161 | array( |
|
| 162 | 'dimensions' => 'ga:fullReferrer', |
|
| 163 | 'sort' => '-ga:pageviews', |
|
| 164 | 'max-results' => $maxResults |
|
| 165 | ) |
|
| 166 | ); |
|
| 167 | ||
| 168 | if (is_null($answer->rows)) { |
|
| 169 | return array(); |
|
| 170 | } |
|
| 171 | ||
| 172 | $referrerData = array(); |
|
| 173 | ||
| 174 | foreach ($answer->rows as $pageRow) { |
|
| 175 | $referrerData[] = array( |
|
| 176 | 'url' => $pageRow[0], |
|
| 177 | 'pageViews' => $pageRow[1] |
|
| 178 | ); |
|
| 179 | } |
|
| 180 | ||
| 181 | return $referrerData; |
|
| 182 | } |
|
| 183 | ||
| 184 | /** |
|
| 185 | * Get the top browsers. |
|
| @@ 288-315 (lines=28) @@ | ||
| 285 | * @param int $maxResults |
|
| 286 | * @return array |
|
| 287 | */ |
|
| 288 | public function getMostVisitedPagesForPeriod(DateTime $startDate, DateTime $endDate, $maxResults = 20) |
|
| 289 | { |
|
| 290 | $answer = $this->performQuery( |
|
| 291 | $startDate, |
|
| 292 | $endDate, |
|
| 293 | 'ga:pageviews', |
|
| 294 | array( |
|
| 295 | 'dimensions' => 'ga:pagePath', |
|
| 296 | 'sort' => '-ga:pageviews', |
|
| 297 | 'max-results' => $maxResults |
|
| 298 | ) |
|
| 299 | ); |
|
| 300 | ||
| 301 | if (is_null($answer->rows)) { |
|
| 302 | return array(); |
|
| 303 | } |
|
| 304 | ||
| 305 | $pagesData = array(); |
|
| 306 | ||
| 307 | foreach ($answer->rows as $pageRow) { |
|
| 308 | $pagesData[] = array( |
|
| 309 | 'url' => $pageRow[0], |
|
| 310 | 'pageViews' => $pageRow[1] |
|
| 311 | ); |
|
| 312 | } |
|
| 313 | ||
| 314 | return $pagesData; |
|
| 315 | } |
|
| 316 | ||
| 317 | /** |
|
| 318 | * Returns the site id (ga:xxxxxxx) for the given url. |
|