@@ 44-55 (lines=12) @@ | ||
41 | return $this; |
|
42 | } |
|
43 | ||
44 | public function fetchVisitorsAndPageViews(DateTime $startDate, DateTime $endDate): Collection |
|
45 | { |
|
46 | $response = $this->performQuery($startDate, $endDate, 'ga:users,ga:pageviews', ['dimensions' => 'ga:date']); |
|
47 | ||
48 | return collect($response['rows'] ?? [])->map(function (array $dateRow) { |
|
49 | return [ |
|
50 | 'date' => Carbon::createFromFormat('Ymd', $dateRow[0]), |
|
51 | 'visitors' => (int) $dateRow[1], |
|
52 | 'pageViews' => (int) $dateRow[2], |
|
53 | ]; |
|
54 | }); |
|
55 | } |
|
56 | ||
57 | public function fetchMostVisitedPages(DateTime $startDate, DateTime $endDate, int $maxResults = 20): Collection |
|
58 | { |
|
@@ 57-68 (lines=12) @@ | ||
54 | }); |
|
55 | } |
|
56 | ||
57 | public function fetchMostVisitedPages(DateTime $startDate, DateTime $endDate, int $maxResults = 20): Collection |
|
58 | { |
|
59 | $response = $this->performQuery($startDate, $endDate, 'ga:pageviews', ['dimensions' => 'ga:pagePath', 'sort' => '-ga:pageviews', 'max-results' => $maxResults]); |
|
60 | ||
61 | return collect($response['rows'] ?? []) |
|
62 | ->map(function (array $pageRow) { |
|
63 | return [ |
|
64 | 'url' => $pageRow[0], |
|
65 | 'pageViews' => (int) $pageRow[1], |
|
66 | ]; |
|
67 | }); |
|
68 | } |
|
69 | ||
70 | public function fetchTopReferrers(DateTime $startDate, DateTime $endDate, int $maxResults = 20): Collection |
|
71 | { |
|
@@ 70-80 (lines=11) @@ | ||
67 | }); |
|
68 | } |
|
69 | ||
70 | public function fetchTopReferrers(DateTime $startDate, DateTime $endDate, int $maxResults = 20): Collection |
|
71 | { |
|
72 | $response = $this->performQuery($startDate, $endDate, 'ga:pageviews', ['dimensions' => 'ga:fullReferrer', 'sort' => '-ga:pageviews', 'max-results' => $maxResults]); |
|
73 | ||
74 | return collect($response['rows'] ?? [])->map(function (array $pageRow) { |
|
75 | return [ |
|
76 | 'url' => $pageRow[0], |
|
77 | 'pageViews' => (int) $pageRow[1], |
|
78 | ]; |
|
79 | }); |
|
80 | } |
|
81 | ||
82 | public function fetchTopBrowsers(DateTime $startDate, DateTime $endDate, int $maxResults = 10): Collection |
|
83 | { |