From d5ea26df1d042ff561444e83076f2e7a71f8be6b Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 9 Jan 2017 02:20:37 +0200 Subject: [PATCH] ga --- backend/views/report/index.php | 48 ++++++------------------------------------------ 1 file changed, 6 insertions(+), 42 deletions(-) diff --git a/backend/views/report/index.php b/backend/views/report/index.php index 5a36151..ddaa354 100644 --- a/backend/views/report/index.php +++ b/backend/views/report/index.php @@ -66,6 +66,12 @@ function getReport($analytics) { $sessions->setExpression("ga:sessions"); $sessions->setAlias("sessions"); + // Создание объекта Sort. + $sessions = new Google_Service_AnalyticsReporting_Sort(); + $sessions->setExpression("ga:country,ga:browser"); + $sessions->setAlias("country,browser"); + + // Создание объекта ReportRequest. $request = new Google_Service_AnalyticsReporting_ReportRequest(); $request->setViewId($VIEW_ID); @@ -106,46 +112,4 @@ function printResults($reports) { } } -/** - * Note: This code assumes you have an authorized Analytics service object. - * See the Segments Developer Guide for details. - */ - -/** - * Example #1: - * Requests a list of all Segments for the authorized user. - */ -try { - $segments = $analytics->management_segments->listManagementSegments(); -} catch (apiServiceException $e) { - print 'There was an Analytics API service error ' - . $e->getCode() . ':' . $e->getMessage(); - -} catch (apiException $e) { - print 'There was a general API error ' - . $e->getCode() . ':' . $e->getMessage(); -} - - -/* - * Example #2: - * The results of the list method are stored in the segments object. - * The following code shows how to iterate through them. - */ -foreach ($segments->getItems() as $segment) { - $html .= << - -Segment ID = {$segment->getId()} -Kind = {$segment->getKind()} -Self Link = {$segment->getSelfLink()} -Name = {$segment->getName()} -Definition = {$segment->getDefinition()} -Created = {$segment->getCreated()} -Updated = {$segment->getUpdated()} - - -HTML; - print $html; -} -- libgit2 0.21.4