Commit d5ea26df1d042ff561444e83076f2e7a71f8be6b
1 parent
ee720a54
ga
Showing
1 changed file
with
6 additions
and
42 deletions
Show diff stats
backend/views/report/index.php
| @@ -66,6 +66,12 @@ function getReport($analytics) { | @@ -66,6 +66,12 @@ function getReport($analytics) { | ||
| 66 | $sessions->setExpression("ga:sessions"); | 66 | $sessions->setExpression("ga:sessions"); |
| 67 | $sessions->setAlias("sessions"); | 67 | $sessions->setAlias("sessions"); |
| 68 | 68 | ||
| 69 | + // Создание объекта Sort. | ||
| 70 | + $sessions = new Google_Service_AnalyticsReporting_Sort(); | ||
| 71 | + $sessions->setExpression("ga:country,ga:browser"); | ||
| 72 | + $sessions->setAlias("country,browser"); | ||
| 73 | + | ||
| 74 | + | ||
| 69 | // Создание объекта ReportRequest. | 75 | // Создание объекта ReportRequest. |
| 70 | $request = new Google_Service_AnalyticsReporting_ReportRequest(); | 76 | $request = new Google_Service_AnalyticsReporting_ReportRequest(); |
| 71 | $request->setViewId($VIEW_ID); | 77 | $request->setViewId($VIEW_ID); |
| @@ -106,46 +112,4 @@ function printResults($reports) { | @@ -106,46 +112,4 @@ function printResults($reports) { | ||
| 106 | } | 112 | } |
| 107 | } | 113 | } |
| 108 | 114 | ||
| 109 | -/** | ||
| 110 | - * Note: This code assumes you have an authorized Analytics service object. | ||
| 111 | - * See the Segments Developer Guide for details. | ||
| 112 | - */ | ||
| 113 | - | ||
| 114 | -/** | ||
| 115 | - * Example #1: | ||
| 116 | - * Requests a list of all Segments for the authorized user. | ||
| 117 | - */ | ||
| 118 | -try { | ||
| 119 | - $segments = $analytics->management_segments->listManagementSegments(); | ||
| 120 | -} catch (apiServiceException $e) { | ||
| 121 | - print 'There was an Analytics API service error ' | ||
| 122 | - . $e->getCode() . ':' . $e->getMessage(); | ||
| 123 | - | ||
| 124 | -} catch (apiException $e) { | ||
| 125 | - print 'There was a general API error ' | ||
| 126 | - . $e->getCode() . ':' . $e->getMessage(); | ||
| 127 | -} | ||
| 128 | - | ||
| 129 | - | ||
| 130 | -/* | ||
| 131 | - * Example #2: | ||
| 132 | - * The results of the list method are stored in the segments object. | ||
| 133 | - * The following code shows how to iterate through them. | ||
| 134 | - */ | ||
| 135 | -foreach ($segments->getItems() as $segment) { | ||
| 136 | - $html .= <<<HTML | ||
| 137 | -<pre> | ||
| 138 | - | ||
| 139 | -Segment ID = {$segment->getId()} | ||
| 140 | -Kind = {$segment->getKind()} | ||
| 141 | -Self Link = {$segment->getSelfLink()} | ||
| 142 | -Name = {$segment->getName()} | ||
| 143 | -Definition = {$segment->getDefinition()} | ||
| 144 | -Created = {$segment->getCreated()} | ||
| 145 | -Updated = {$segment->getUpdated()} | ||
| 146 | - | ||
| 147 | -</pre> | ||
| 148 | -HTML; | ||
| 149 | - print $html; | ||
| 150 | -} | ||
| 151 | 115 |