当前位置: 首页>>代码示例>>PHP>>正文


PHP gapi::requestReportData方法代码示例

本文整理汇总了PHP中gapi::requestReportData方法的典型用法代码示例。如果您正苦于以下问题:PHP gapi::requestReportData方法的具体用法?PHP gapi::requestReportData怎么用?PHP gapi::requestReportData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gapi的用法示例。


在下文中一共展示了gapi::requestReportData方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: GoogleAnalyticsPopularPosts_widget_output

function GoogleAnalyticsPopularPosts_widget_output()
{
    $GAPP_usr = get_option('GoogleAnalyticsPopularPosts_username');
    $GAPP_pwd = get_option('GoogleAnalyticsPopularPosts_password');
    $GAPP_pID = get_option('GoogleAnalyticsPopularPosts_profileID');
    $GAPP_mRs = get_option('GoogleAnalyticsPopularPosts_maxResults');
    $GAPP_SDs = get_option('GoogleAnalyticsPopularPosts_statsSinceDays');
    $GAPP_filter = get_option('GoogleAnalyticsPopularPosts_filter');
    $GAPP_dDisp = get_option('GoogleAnalyticsPopularPosts_dateDispEnable');
    $GAPP_pDisp = get_option('GoogleAnalyticsPopularPosts_postDateEnable');
    $GAPP_cView = get_option('GoogleAnalyticsPopularPosts_contentsViewEnable');
    if (is_numeric($GAPP_SDs)) {
        $todays_year = date("Y");
        $todays_month = date("m");
        $todays_day = date("d");
        $date = "{$todays_year}-{$todays_month}-{$todays_day}";
        $newdate = strtotime("-{$GAPP_SDs} day", strtotime($date));
        $newdate = date('Y-m-d', $newdate);
        $From = $newdate;
    }
    define('ga_email', $GAPP_usr);
    define('ga_password', $GAPP_pwd);
    define('ga_profile_id', $GAPP_pID);
    if (!ga_email || !ga_password || !ga_profile_id) {
        $output = __('<b>Google Analytics Popular Posts Error :</b><br />Please enter your account details in the options page.', 'google-analytics-popular-posts');
        return $output;
    }
    $GAPP_filter_fixed = 'ga:pagePath=~^/';
    require 'gapi.class.php';
    $ga = new gapi(ga_email, ga_password);
    $ga->requestReportData(ga_profile_id, array('hostname', 'pagePath'), array('visits'), array('-visits'), $filter = $GAPP_filter_fixed . $GAPP_filter, $start_date = $From, $end_date = $date, $start_index = 1, $max_results = $GAPP_mRs);
    if ($GAPP_dDisp == "yes") {
        $output = '<p class="popular_stats_date">' . $From . ' ~ ' . $date . '</p>' . "\n";
    }
    foreach ($ga->getResults() as $result) {
        $getHostname = $result->getHostname();
        $getPagepath = $result->getPagepath();
        $postPagepath = 'http://' . $getHostname . $getPagepath;
        $getPostID = url_to_postid($postPagepath);
        if ($getPostID <= 0) {
            $titleStr = $postPagepath;
            $output .= '<ul>' . "\n";
            $output .= '<li>' . "\n";
            $output .= '<div class="popular_post"><a href=' . $postPagepath . '>' . $titleStr . '</a></div>' . "\n";
            $output .= '</li>' . "\n";
            $output .= '</ul>' . "\n";
        } else {
            $titleStr = get_the_title($getPostID);
            $post = get_post($getPostID);
            $dateStr = mysql2date('Y-m-d', $post->post_date);
            $contentStr = strip_tags(mb_substr($post->post_content, 0, 60));
            $output .= '<ul>' . "\n";
            $output .= '<li>' . "\n";
            $output .= '<div class="popular_post"><a href=' . $postPagepath . '>' . $titleStr . '</a><br />' . "\n";
            if ($GAPP_pDisp == "yes" and $GAPP_cView == "yes") {
                $output .= '<div class="popular_post_date">' . $dateStr . '<br /></div>' . "\n";
                $output .= '<div class="popular_post_contents">' . $contentStr . ' ...' . '</div>' . "\n";
            } elseif ($GAPP_pDisp == "yes" and $GAPP_cView == "no") {
                $output .= '<div class="popular_post_date">' . $dateStr . '<br /></div>' . "\n";
            } elseif ($GAPP_pDisp == "no" and $GAPP_cView == "yes") {
                $output .= '<div class="popular_post_contents">' . $contentStr . ' ...' . '</div>' . "\n";
            } else {
            }
            $output .= '</div>' . "\n";
            $output .= '</li>' . "\n";
            $output .= '</ul>' . "\n";
        }
    }
    return $output;
}
开发者ID:ligun,项目名称:wp-google-analytics-popular-posts2,代码行数:70,代码来源:google-analytics-popular-posts.php

示例2: get_dashboard_report

 /**
  *
  */
 public function get_dashboard_report()
 {
     if (self::$should_access) {
         try {
             $dataRows = array();
             $ga = new gapi(self::$ga_email, self::$ga_password);
             // Main data
             $ga->requestReportData(self::$ga_profile_id, 'pagePath', array('pageviews', 'uniquePageviews', 'exitRate', 'avgTimeOnPage', 'entranceBounceRate'), null, 'pagePath == /');
             $mainData = $ga->getResults();
             // Visits data
             $ga->requestReportData(self::$ga_profile_id, 'date', array('visitors', 'newVisits', 'visits'), 'date');
             $visitorData = $ga->getResults();
             if (!empty($mainData[0])) {
                 $result = $mainData[0];
                 $data = array('pageViews' => number_format($result->getPageviews(), 0, null, ' '), 'uniquePageViews' => number_format($result->getUniquePageviews(), 0, null, ' '), 'avgTimeOnPage' => $this->secondMinute($result->getAvgtimeOnpage()), 'bounceRate' => round($result->getEntranceBounceRate(), 2) . '%');
                 $data['visitors'] = 0;
                 $data['visits'] = 0;
                 $data['newVisits'] = 0;
                 if (!empty($visitorData)) {
                     foreach ($visitorData as $vd) {
                         $data['visitors'] += $vd->getVisitors();
                         $data['visits'] += $vd->getVisits();
                         $data['newVisits'] += $vd->getNewVisits();
                         $dataRows[] = array(date('M j', strtotime($vd->getDate())), $vd->getVisits(), $vd->getNewVisits());
                     }
                     $data['visitors'] = number_format($data['visitors'], 0, null, ' ');
                     $data['visits'] = number_format($data['visits'], 0, null, ' ');
                     $data['newVisits'] = number_format($data['newVisits'], 0, null, ' ');
                 }
                 $this->template['data'] = $data;
             }
             // Get the Last 30 days data
             /*
             $ga->requestReportData(
             	self::$ga_profile_id,
             	array('date'),
             	array('pageviews','uniquePageviews'),
             	'date',
             	'pagePath == /'
             );
             $chartResults = $ga->getResults();
             foreach($chartResults as $result)
             {
             	$dataRows[] = array(
             		date('M j', strtotime($result->getDate())),
             		$result->getPageviews(),
             		$result->getUniquePageviews()
             	);
             }
             */
             $this->template['dataRows'] = json_encode($dataRows, true);
             $this->output('google/dashboard_report');
         } catch (Exception $e) {
             echo $e->getMessage();
         }
     }
 }
开发者ID:pompalini,项目名称:emngo,代码行数:60,代码来源:google.php

示例3: date

 function __construct($email, $password, $uid, $start_date = null, $end_date = null)
 {
     $filter = '';
     $this->initialstartdate = date('M j Y', strtotime($start_date));
     $this->initialenddate = date('M j Y', strtotime($end_date));
     $start_index = 1;
     $perdayCounts = $this->createDateRangeArray($start_date, $end_date);
     $max_result = 1000000000;
     $ga = new gapi($email, $password);
     $ga->requestReportData($uid, array('date', 'source', 'medium', 'referralPath'), array('pageviews', 'visits', 'entranceBounceRate', 'timeOnSite', 'newVisits'), 'date', $filter, $start_date, $end_date, $start_index, $max_result);
     $result = $ga->getResults();
     $this->pageViews = $ga->getPageviews();
     $this->visits = $ga->getVisits();
     $this->bounceRate = $ga->getentranceBounceRate();
     $this->timeOnSite = $ga->gettimeOnSite() / $this->visits / 60;
     $this->newVisits = round($ga->getnewVisits() / $this->visits * 100, 2);
     foreach ($result as $key => $value) {
         $this->source[] = array('medium' => $value->getMedium(), 'visit' => $value->getVisits(), 'source' => $value->getSource());
         $this->dateWise[] = array($value->getDate() => $value->getPageviews());
     }
     foreach ($perdayCounts as $day) {
         $new_array = '';
         foreach ($this->dateWise as $breakPoint) {
             foreach ($breakPoint as $key => $value) {
                 if ($key == $day) {
                     $new_array[] = $value;
                 }
             }
         }
         $this->valueCountsPerDay[] = array($day => array_sum($new_array));
     }
 }
开发者ID:habbash18,项目名称:netefct,代码行数:32,代码来源:class.analytics.php

示例4: get_analytics_data

 public function get_analytics_data()
 {
     $flot_datas_visits = array();
     $analytics = Config::get('cms::settings.analytics.profile_id');
     if (!empty($analytics)) {
         $id = Config::get('cms::settings.analytics.id');
         $account = Config::get('cms::settings.analytics.account');
         $password = Config::get('cms::settings.analytics.password');
         $pid = Config::get('cms::settings.analytics.profile_id');
         //CACHE DATA
         if (CACHE) {
             $show_data = Cache::remember('analytics_' . $pid, function () use($pid, $account, $password) {
                 $ga = new gapi($account, $password);
                 $ga->requestReportData($pid, array('date'), array('visits'), array('date'), null, date("Y-m-d", strtotime("-30 days")), date("Y-m-d"));
                 $results = $ga->getResults();
                 foreach ($results as $result) {
                     $flot_datas_visits[] = '[' . strtotime($result->getDate()) * 1000 . ',' . $result->getVisits() . ']';
                 }
                 return $show_data = '[' . implode(',', $flot_datas_visits) . ']';
             }, 1440);
             //CACHE DISABLED
         } else {
             $ga = new gapi($account, $password);
             $ga->requestReportData($pid, array('date'), array('visits'), array('date'), null, date("Y-m-d", strtotime("-30 days")), date("Y-m-d"));
             $results = $ga->getResults();
             foreach ($results as $result) {
                 $flot_datas_visits[] = '[' . strtotime($result->getDate()) * 1000 . ',' . $result->getVisits() . ']';
             }
             $show_data = '[' . implode(',', $flot_datas_visits) . ']';
         }
         return $show_data;
     }
 }
开发者ID:SerdarSanri,项目名称:PongoCMS-Laravel-cms-bundle,代码行数:33,代码来源:dashboard.php

示例5: run

 public function run()
 {
     class_exists('gapi') or (require dirname(__FILE__) . '/../../../vendor/gapi/gapi.class.php');
     $ga = new gapi($this->email, $this->password);
     $ga->requestReportData($this->profile_id, array('date'), array($this->metric), null, null, date('Y-m-d', strtotime('yesterday')), date('Y-m-d', strtotime('-' . $this->time)));
     $methodName = 'get' . ucFirst($this->metric);
     $this->result = $ga->{$methodName}();
     return parent::afterConstruct();
 }
开发者ID:holdensmagicalunicorn,项目名称:franklin,代码行数:9,代码来源:GoogleAnalyticsAPITest.php

示例6: listing

 function listing()
 {
     $dimensions = array('month');
     $metrics = array('visits', 'newvisits', 'pageviews', 'timeonsite');
     $sort = array('month');
     $filter = '';
     $ga = new gapi('', '');
     $d['full'] = $ga->requestReportData($_SESSION['cmsgaprofile'], $dimensions, $metrics, $sort, $filter, '2015-01-01', '2015-12-31', 1, 999);
     $this->set($d);
 }
开发者ID:WebPassions,项目名称:2015,代码行数:10,代码来源:StatisticController.php

示例7: getMetrics

 public function getMetrics()
 {
     $json = array();
     $keys = array('username', 'password', 'date_ini', 'date_end');
     foreach ($keys as $key) {
         if (isset($this->request->post[$key])) {
             ${$key} = $this->request->post[$key];
         } else {
             ${$key} = '';
         }
     }
     $this->load->model('account/api');
     $api_info = $this->model_account_api->login($username, $password);
     if ($api_info) {
         if ($date_ini && $date_end) {
             $json['quantity_email'] = (int) $this->model_account_api->getTotalEmails();
             $json['quantity_product'] = (int) $this->model_account_api->getTotalProducts();
             $json['quantity_billing'] = (double) $this->model_account_api->getBillingStore($date_ini, $date_end);
             require_once DIR_SYSTEM . "library/gapi.php";
             $key = DIR_APPLICATION . 'controller/api/key/' . $api_info['email'] . '.p12';
             $ga = new gapi($api_info['email'], $key);
             $results = $ga->requestAccountData();
             $id = '';
             foreach ($results['items'] as $perfil) {
                 for ($i = 0; $i < count($perfil['webProperties']); $i++) {
                     if ($perfil['webProperties'][$i]['id'] == $this->config->get('config_google_analytics')) {
                         $count = count($perfil['webProperties'][$i]['profiles']) - 1;
                         $id = $perfil['webProperties'][$i]['profiles'][$count]['id'];
                     }
                 }
             }
             if ($id) {
                 $ga->requestReportData($id, 'day', array('pageviews', 'visits'), 'day', null, $date_ini, $date_end, 1, 50);
                 $pageviews = 0;
                 foreach ($ga->getResults() as $dados) {
                     $pageviews += $dados->getPageviews();
                 }
                 $json['quantity_pageview'] = (int) $pageviews;
             } else {
                 $json['quantity_pageview'] = 'A conta do usúario não foi encontrada no Google Analytics';
             }
         }
     } else {
         $json['error'] = 'Token Inválido';
     }
     $this->response->addHeader('Content-Type: application/json');
     $this->response->setOutput(json_encode($json));
 }
开发者ID:luanmpereira,项目名称:default-store,代码行数:48,代码来源:billing.php

示例8: gAnalytics

 /**
  * Obter informações do Google Analytics
  *
  * @param string $dt_inicio Data de início da consulta
  * @param string $dt_fim    Data final da consulta
  * @param string $dimensao  Dimensão a ser utilizada para agrupar os resultados
  * @param array  $metricas
  *
  * @throws \DL3Exception
  */
 public function gAnalytics($dt_inicio, $dt_fim, $dimensao = 'day', $metricas = ['visits'])
 {
     # Selecionar as configurações do Google Analytics
     $m_ga = new WebM\GoogleAnalytics();
     $m_ga->selecionarPrincipal();
     # Conectar ao Google Analytics
     $o_ga = new \gapi($m_ga->contaCompleta(), $m_ga->getP12());
     # Retornar as informações
     $o_ga->requestReportData($m_ga->getPerfilId(), $dimensao, !isset($metricas) ? ['visits'] : $metricas, null, null, \Funcoes::formatarDataHora($dt_inicio, 'Y-m-d'), \Funcoes::formatarDataHora($dt_fim, 'Y-m-d'));
     # Visitas
     $infos = [];
     foreach ($o_ga->getResults() as $info) {
         $infos[] = ['dimensao' => (string) $info, 'visitas' => $info->getVisits()];
     }
     // Fim foreach
     echo json_encode($infos);
 }
开发者ID:dlepera,项目名称:painel-dl,代码行数:27,代码来源:website.controle.php

示例9: _monthPageViewsVisits

 /**
  * A temporary function to hold the first example of a chart data return.
  * We can make this more robust and to handle more uses cases.
  * @todo  	Make an entire analytics plugin to be part of the reports plugin.
  */
 public function _monthPageViewsVisits()
 {
     if (!empty($instance) && defined('__REPORTS_ANALYTICS_' . $instance)) {
         extract(unserialize(constant('__REPORTS_ANALYTICS_' . $instance)));
     } else {
         if (defined('__REPORTS_ANALYTICS')) {
             extract(unserialize(__REPORTS_ANALYTICS));
         }
     }
     if (!empty($userName) && !empty($password) && !empty($setAccount)) {
         App::import('Vendor', 'Reports.gapi');
         $ga = new gapi($userName, $password, isset($_SESSION['ga_auth_token']) ? $_SESSION['ga_auth_token'] : null);
         $_SESSION['ga_auth_token'] = $ga->getAuthToken();
         // $filter = 'country == United States && browser == Firefox || browser == Chrome';
         // $report_id, $dimensions, $metrics, $sort_metric=null, $filter=null, $start_date=null, $end_date=null, $start_index=1, $max_results=30
         // http://code.google.com/apis/analytics/docs/gdata/gdataReferenceDimensionsMetrics.html#ga:visitors
         foreach ($ga->requestAccountData() as $account) {
             if (is_object($account)) {
                 if ($account->properties['webPropertyId'] == $setAccount) {
                     $reportId = $account->properties['profileId'];
                 }
             }
         }
         $backMonth = date('Y-m-d', mktime(0, 0, 0, date("m") - 1, date("d"), date("Y")));
         $ga->requestReportData(53475, array('date'), array('pageviews', 'visits'), 'date', null, $backMonth, date('Y-m-d'));
         $i = 0;
         foreach ($ga->getResults() as $result) {
             #debug($result);
             $chartData[$i]['pageviews'] = $result->getPageviews();
             $chartData[$i]['visits'] = $result->getVisits();
             $chartData[$i]['date'] = $result->getDate();
             $i++;
         }
         $chartData['totalResults'] = $ga->getTotalResults();
         $chartData['totalPageViews'] = $ga->getPageviews();
         $chartData['totalVisits'] = $ga->getVisits();
         $chartData['updated'] = $ga->getUpdated();
         return $chartData;
     } else {
         // google analytics username and password must be set in settings (__REPORTS_ANALYTICS)
         return;
     }
 }
开发者ID:ayaou,项目名称:Zuha,代码行数:48,代码来源:WebpageReportsController.php

示例10: info

 private function info($id)
 {
     $results = array();
     if ($id == null) {
         $results = SearchKeywords::getKeywords($this->url);
     } else {
         $ga = new gapi(config::ga_email, config::ga_password);
         $start = date('Y-m-d', strtotime('-1 day'));
         $end = date('Y-m-d', strtotime('-1 day'));
         $ga->requestReportData($id, array('keyword'), array('visits'), '-visits', null, $start, $end);
         foreach ($ga->getResults() as $r) {
             $results[1][] = $r->getKeyword();
             $results[2][] = $r->getVisits();
         }
     }
     for ($j = 0; $j < count($results[1]); ++$j) {
         if ($results[1][$j] != "(not set)") {
             $this->keys[] = array("keyword" => $results[1][$j], "visits" => $results[2][$j], "pos" => $this->keywordPosition($results[1][$j]));
         }
     }
 }
开发者ID:roozbeh360,项目名称:WebKeyPerformance,代码行数:21,代码来源:webkeyperformance.class.php

示例11: array

 function fetch_daily_stats($ga_user, $ga_password, $ga_profile_id)
 {
     global $LOC;
     $data = array();
     $data['cache_date'] = date('Y-m-d', $LOC->set_localized_time());
     require_once PATH_LIB . 'analytics_panel/gapi.class.php';
     // Compile yesterday's stats
     $yesterday = new gapi($ga_user, $ga_password);
     $ga_auth_token = $yesterday->getAuthToken();
     $yesterday->requestReportData($ga_profile_id, array('date'), array('pageviews', 'visits', 'timeOnSite'), '', '', date('Y-m-d', strtotime('yesterday')), date('Y-m-d', strtotime('yesterday')));
     // Get account data so we can store the profile info
     $data['profile'] = array();
     $yesterday->requestAccountData(1, 100);
     foreach ($yesterday->getResults() as $result) {
         if ($result->getProfileId() == $ga_profile_id) {
             $data['profile']['id'] = $result->getProfileId();
             $data['profile']['title'] = $result->getTitle();
         }
     }
     $data['yesterday']['visits'] = number_format($yesterday->getVisits());
     $data['yesterday']['pageviews'] = number_format($yesterday->getPageviews());
     $data['yesterday']['pages_per_visit'] = $this->analytics_avg_pages($yesterday->getPageviews(), $yesterday->getVisits());
     $data['yesterday']['avg_visit'] = $this->analytics_avg_visit($yesterday->getTimeOnSite(), $yesterday->getVisits());
     // Compile last month's stats
     $lastmonth = new gapi($ga_user, $ga_password, $ga_auth_token);
     $lastmonth->requestReportData($ga_profile_id, array('date'), array('pageviews', 'visits', 'newVisits', 'timeOnSite', 'bounces', 'entrances'), 'date', '', date('Y-m-d', strtotime('31 days ago')), date('Y-m-d', strtotime('yesterday')));
     $data['lastmonth']['date_span'] = date('F jS Y', strtotime('31 days ago')) . ' &ndash; ' . date('F jS Y', strtotime('yesterday'));
     $data['lastmonth']['visits'] = number_format($lastmonth->getVisits());
     $data['lastmonth']['visits_sparkline'] = $this->analytics_sparkline($lastmonth->getResults(), 'visits');
     $data['lastmonth']['pageviews'] = number_format($lastmonth->getPageviews());
     $data['lastmonth']['pageviews_sparkline'] = $this->analytics_sparkline($lastmonth->getResults(), 'pageviews');
     $data['lastmonth']['pages_per_visit'] = $this->analytics_avg_pages($lastmonth->getPageviews(), $lastmonth->getVisits());
     $data['lastmonth']['pages_per_visit_sparkline'] = $this->analytics_sparkline($lastmonth->getResults(), 'avgpages');
     $data['lastmonth']['avg_visit'] = $this->analytics_avg_visit($lastmonth->getTimeOnSite(), $lastmonth->getVisits());
     $data['lastmonth']['avg_visit_sparkline'] = $this->analytics_sparkline($lastmonth->getResults(), 'time');
     $data['lastmonth']['bounce_rate'] = $lastmonth->getBounces() > 0 && $lastmonth->getBounces() > 0 ? round($lastmonth->getBounces() / $lastmonth->getEntrances() * 100, 2) . '%' : '0%';
     $data['lastmonth']['bounce_rate_sparkline'] = $this->analytics_sparkline($lastmonth->getResults(), 'bouncerate');
     $data['lastmonth']['new_visits'] = $lastmonth->getNewVisits() > 0 && $lastmonth->getVisits() > 0 ? round($lastmonth->getNewVisits() / $lastmonth->getVisits() * 100, 2) . '%' : '0%';
     $data['lastmonth']['new_visits_sparkline'] = $this->analytics_sparkline($lastmonth->getResults(), 'newvisits');
     // Compile last month's top content
     $topcontent = new gapi($ga_user, $ga_password, $ga_auth_token);
     $topcontent->requestReportData($ga_profile_id, array('hostname', 'pagePath'), array('pageviews'), '-pageviews', '', date('Y-m-d', strtotime('31 days ago')), date('Y-m-d', strtotime('yesterday')), null, 20);
     $data['lastmonth']['content'] = array();
     $i = 0;
     // Make a temporary array to hold page paths
     // (for checking dupes resulting from www vs non-www hostnames)
     $paths = array();
     foreach ($topcontent->getResults() as $result) {
         // Do we already have this page path?
         $dupe_key = array_search($result->getPagePath(), $paths);
         if ($dupe_key !== FALSE) {
             // Combine the pageviews of the dupes
             $data['lastmonth']['content'][$dupe_key]['count'] = $result->getPageviews() + $data['lastmonth']['content'][$dupe_key]['count'];
         } else {
             $url = strlen($result->getPagePath()) > 30 ? substr($result->getPagePath(), 0, 30) . '&hellip;' : $result->getPagePath();
             $data['lastmonth']['content'][$i]['title'] = '<a href="http://' . $result->getHostname() . $result->getPagePath() . '" target="_blank">' . $url . '</a>';
             $data['lastmonth']['content'][$i]['count'] = $result->getPageviews();
             // Store the page path at the same position so we can check for dupes
             $paths[$i] = $result->getPagePath();
             $i++;
         }
     }
     // Slice down to 10 results
     $data['lastmonth']['content'] = array_slice($data['lastmonth']['content'], 0, 10);
     // Compile last month's top referrers
     $referrers = new gapi($ga_user, $ga_password, $ga_auth_token);
     $referrers->requestReportData($ga_profile_id, array('source', 'referralPath', 'medium'), array('visits'), '-visits', '', date('Y-m-d', strtotime('31 days ago')), date('Y-m-d', strtotime('yesterday')), null, 10);
     $data['lastmonth']['referrers'] = array();
     $i = 0;
     foreach ($referrers->getResults() as $result) {
         $data['lastmonth']['referrers'][$i]['title'] = $result->getMedium() == 'referral' ? '<a href="http://' . $result->getSource() . $result->getReferralPath() . '" target="_blank">' . $result->getSource() . '</a>' : $result->getSource();
         $data['lastmonth']['referrers'][$i]['count'] = number_format($result->getVisits());
         $i++;
     }
     return $data;
 }
开发者ID:amphibian,项目名称:ext.analytics_panel.ee_addon,代码行数:76,代码来源:ext.analytics_panel.php

示例12: gapi

<?php

require 'gapi.class.php';
define('ga_profile_id', 'your profile id');
$ga = new gapi("XXXXXXXX@developer.gserviceaccount.com", "key.p12");
$ga->requestReportData(ga_profile_id, array('browser', 'browserVersion'), array('pageviews', 'visits'));
?>
<table>
<tr>
  <th>Browser &amp; Browser Version</th>
  <th>Pageviews</th>
  <th>Visits</th>
</tr>
<?php 
foreach ($ga->getResults() as $result) {
    ?>
<tr>
  <td><?php 
    echo $result;
    ?>
</td>
  <td><?php 
    echo $result->getPageviews();
    ?>
</td>
  <td><?php 
    echo $result->getVisits();
    ?>
</td>
</tr>
<?php 
开发者ID:PrafullaKumarSahu,项目名称:gapi-google-analytics-php-interface,代码行数:31,代码来源:example.report.php

示例13: json_encode

<?php

// ajax_ga_geo.php
require_once 'includes/global.inc.php';
// initialize the google analytics object
$ga = new gapi($ga_email, $ga_password);
$dimensions = array('region');
$metrics = array('visits', 'pageviewsPerVisit', 'avgTimeOnSite', 'percentNewVisits');
$filters = "country==India";
$ga->requestReportData($ga_profile, $dimensions, $metrics, '-visits', $filters, '2012-03-01', '2012-04-10', 1, 50);
$geo_data = array();
foreach ($ga->getResults() as $result) {
    $region = $result->getRegion();
    $visits = $result->getVisits();
    $arr = array("region" => $region, "visits" => $visits);
    array_push($geo_data, $arr);
}
echo json_encode($geo_data);
开发者ID:rajasegar,项目名称:brokerarena,代码行数:18,代码来源:ajax_ga_geo.php

示例14: gapi

<?php

error_reporting(15);
//конфиг
//include("config.php");
//подключаем класс GA API
include "gapi.class.php";
$ga = new gapi($u, $p);
//////получаем пользователи/просмотры за все время
$ga->requestReportData($id, array('month', 'year'), array('visitors', 'pageviews'), 'year', null, $datestart, $datefinish, 1, 1000);
//переменная для записи резалта
$output = "";
if ($addFile) {
    $add = file_get_contents($path . $addFile);
    $output .= trim($add) . "\n";
}
//получаем и обрабатываем результаты
foreach ($ga->getResults() as $result) {
    $m = $result;
    //месяц год
    $visitors = $result->getVisitors();
    //посетители
    $pageviews = $result->getPageviews();
    //просмотры
    //приводим дату к удобочитаемому виду ,мменяем пробелы на точки
    $m = str_replace(" ", ".", $m);
    //формируем строку
    $output .= $m . ";" . $visitors . ";" . $pageviews . "\n";
}
//пишем в файл
$fp = fopen($path . $visitorsCSV, "w");
开发者ID:kytvi2p,项目名称:ZettaFramework,代码行数:31,代码来源:stat.php

示例15: actionGoogleAnalytics

 public function actionGoogleAnalytics()
 {
     if (Yii::app()->user->checkAccess('viewGoogleAnalytics') == false) {
         throw new CHttpException(403);
     }
     require_once 'gapi.class.php';
     header('Content-type: application/json');
     try {
         $account = Setting::getValueByCode('google_analytics_account');
         $password = Setting::getValueByCode('google_analytics_password');
         $reportId = Setting::getValueByCode('google_analytics_report_id');
         if (empty($account) || empty($password) || empty($password)) {
             throw new Exception('Google 分析帐号信息未设置');
         }
         $ga = new gapi($account, $password);
         $ga->requestReportData($reportId, array('date'), array('pageviews', 'visits'), array('date', '-pageviews', '-visits'));
         $pageviews = array();
         $visits = array();
         foreach ($ga->getResults() as $result) {
             array_push($pageviews, array(date('Y-n-j', strtotime($result->getDate())), $result->getPageviews()));
             array_push($visits, array(date('Y-n-j', strtotime($result->getDate())), $result->getVisits()));
         }
         echo CJSON::encode(array('result' => true, 'data' => array($pageviews, $visits)));
     } catch (Exception $e) {
         echo CJSON::encode(array('result' => false, 'message' => $e->getMessage()));
     }
     Yii::app()->end();
 }
开发者ID:kinghinds,项目名称:kingtest2,代码行数:28,代码来源:SiteController.php


注:本文中的gapi::requestReportData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。