Commit ee720a547dcf9c99c408b8e3f7a1ed1a2bac971c

Authored by Alex Savenko
1 parent 2a219955

ga

Showing 1 changed file with 44 additions and 17 deletions   Show diff stats
backend/views/report/index.php
@@ -20,23 +20,6 @@ $this->params['breadcrumbs'][] = $this->title; @@ -20,23 +20,6 @@ $this->params['breadcrumbs'][] = $this->title;
20 <h1><?= Html::encode($this->title) ?></h1> 20 <h1><?= Html::encode($this->title) ?></h1>
21 </div> 21 </div>
22 22
23 - <script>  
24 - (function(w,d,s,g,js,fs){  
25 - g=w.gapi||(w.gapi={});g.analytics={q:[],ready:function(f){this.q.push(f);}};  
26 - js=d.createElement(s);fs=d.getElementsByTagName(s)[0];  
27 - js.src='https://apis.google.com/js/platform.js';  
28 - fs.parentNode.insertBefore(js,fs);js.onload=function(){g.load('analytics');};  
29 - }(window,document,'script'));  
30 - </script>  
31 -  
32 - <div id="embed-api-auth-container"></div>  
33 - <div id="chart-container"></div>  
34 - <div id="view-selector-container"></div>  
35 -  
36 -  
37 -  
38 -  
39 -  
40 <?php 23 <?php
41 24
42 // Загрузка клиентской библиотеки PHP для Google API. 25 // Загрузка клиентской библиотеки PHP для Google API.
@@ -122,3 +105,47 @@ function printResults($reports) { @@ -122,3 +105,47 @@ function printResults($reports) {
122 } 105 }
123 } 106 }
124 } 107 }
  108 +
  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 +