Created
June 26, 2017 07:03
-
-
Save atsu666/545b151d92be0b94910d437e089e13ae to your computer and use it in GitHub Desktop.
php/ACMS/GET/Api/GoogleAnalytics/Ranking.php (Ver. 2.6.1.4)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class ACMS_GET_Api_GoogleAnalytics_Ranking extends ACMS_GET_Api_GoogleAnalytics | |
{ | |
function get() | |
{ | |
$Tpl = new Template($this->tpl, new ACMS_Corrector()); | |
$email = config('google_api_app_service_email'); | |
$key = config('google_api_client_id_key_location'); | |
try { | |
$this->getService($email, $key); | |
$this->setStartDate(config('ga_ranking_start_date')); | |
$this->setEndDate(config('ga_ranking_end_date')); | |
$options = array( | |
"dimensions" => "ga:pageTitle, ga:pagePath", | |
"max-results" => config('ga_ranking_max_results', 30), | |
"sort" => "-ga:pageviews", | |
); | |
if ( config('ga_ranking_filters') ) { | |
// e.g. "ga:pagePath=~/(.*)\.html" | |
$options['filters'] = config('ga_ranking_filters'); | |
} | |
$results = $this->getResults('ga:pageviews', $options); | |
if ( count($results->getRows()) === 0 ) { | |
$Tpl->add('notFound'); | |
return $Tpl->get(); | |
} | |
foreach ( $results->getRows() as $row ) { | |
$Tpl->add('ranking:loop', array( | |
'title' => $row[0], | |
'path' => $row[1], | |
'views' => $row[2], | |
)); | |
} | |
} catch ( \Exception $e ) { | |
if ( DEBUG_MODE ) { | |
throw $e; | |
} | |
return ''; | |
} | |
return $Tpl->get(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment