Commit 74a48fa5ab02e7397ea29791e456661f69733bae
1 parent
a1153728
ga
Showing
1 changed file
with
12 additions
and
11 deletions
Show diff stats
backend/views/report/index.php
| ... | ... | @@ -40,17 +40,18 @@ if (isset($_SESSION['access_token']) && $_SESSION['access_token']) { |
| 40 | 40 | $analytics = new Google_Service_AnalyticsReporting($client); |
| 41 | 41 | |
| 42 | 42 | // Вызов the Analytics Reporting API V4. |
| 43 | - $metric_1 = 'ga:sessions'; | |
| 44 | - $metric_2 = 'ga:users'; | |
| 45 | - $metric_3 = 'ga:CTR'; | |
| 46 | - $response_1 = getReport($analytics, $metric_1); | |
| 47 | - $response_2 = getReport($analytics, $metric_2); | |
| 48 | - $response_3 = getReport($analytics, $metric_3); | |
| 49 | - | |
| 50 | - // Вывод ответа. | |
| 51 | - printResults($response_1); | |
| 52 | - printResults($response_2); | |
| 53 | - printResults($response_3); | |
| 43 | + | |
| 44 | + $param[] = ['metric' => 'ga:sessions', 'alias' => 'Сессии']; | |
| 45 | + $param[] = ['metric' => 'ga:users', 'alias' => 'Пользователи']; | |
| 46 | + $param[] = ['metric' => 'ga:CTR', 'alias' => 'CTR']; | |
| 47 | + | |
| 48 | + foreach ($param as $item) { | |
| 49 | + $response = getReport($analytics, $item['metric'], $item['alias']); | |
| 50 | + | |
| 51 | + // Вывод ответа. | |
| 52 | + printResults($response); | |
| 53 | + } | |
| 54 | + | |
| 54 | 55 | |
| 55 | 56 | |
| 56 | 57 | } else { | ... | ... |