Exemplo n.º 1
0
$giorni_giorno = 1;
$data_ricerca_anno = date("Y-m-d", time() - 86400 * $giorni_anno);
$data_ricerca_mese = date("Y-m-d", time() - 86400 * $giorni_mese);
$data_ricerca_settimana = date("Y-m-d", time() - 86400 * $giorni_settimana);
$data_ricerca_giorno = date("Y-m-d", time() - 86400 * $giorni_giorno);
$oggi = date("Y-m-d");
$ga = new gapi(ga_email, ga_password);
//////////////
// GIORNO
//////////////
$ga->requestReportData(ga_profile_id, array('visitorType'), array('visitors', 'pageviews', 'visits', 'timeOnSite', 'avgtimeOnsite', 'percentNewVisits', 'newVisits', 'pageviewsPerVisit', 'uniquePageviews'), '', '', $data_ricerca_giorno, date("Y-m-d"), 1, 1000);
echo "<div class=\"gacounter\">";
echo "<h3>Periodo osservazione: ultimo giorno </h3>";
echo "<p> dal " . date("d-m-Y", time() - 86400 * $giorni_giorno) . " al " . date("d-m-Y") . "</p>";
echo "<ul><li>visite totali: " . $ga->getVisits() . "</li>";
echo "<li class=\"alternato\">visitatori totali: " . $ga->getVisitors() . "</li>";
echo "<li>nuovi visitatori: " . $ga->getnewVisits() . "</li>";
echo "<li class=\"alternato\">pagine viste: " . $ga->getPageviews() . "</li>";
echo "<li>pagine viste per visita: " . round($ga->getpageviewsPerVisit(), 2) . "</li>";
echo "<li class=\"alternato\">pagine uniche: " . $ga->getuniquePageviews() . "</li>";
$t_medio = tempo_medio($ga->getavgTimeOnSite());
echo "<li>tempo medio di permanenza sul sito: " . $t_medio . "</li></ul>";
echo "</div>";
//////////////
// SETTIMANA
//////////////
$ga->requestReportData(ga_profile_id, array('visitorType'), array('visitors', 'pageviews', 'visits', 'timeOnSite', 'avgtimeOnsite', 'percentNewVisits', 'newVisits', 'pageviewsPerVisit', 'uniquePageviews'), '', '', $data_ricerca_settimana, date("Y-m-d"), 1, 1000);
echo "<div class=\"gacounter\">";
echo "<h3>Periodo osservazione: ultimi 7 giorni</h3>";
echo "<p> dal " . date("d-m-Y", time() - 86400 * $giorni_settimana) . " al " . date("d-m-Y") . "</p>";
echo "<ul><li>visite totali: " . $ga->getVisits() . "</li>";
Exemplo n.º 2
0
 function getGAgeneral()
 {
     $app =& JFactory::getApplication();
     $config = $app->getuserState('rsseoConfig');
     try {
         $ga = new gapi($config['analytics.username'], $config['analytics.password'], $config['ga.token']);
         $ga->requestReportData($config['ga.account'], '', array('visits', 'pageviews', 'pageviewsPerVisit', 'avgTimeOnSite', 'visitBounceRate', 'percentNewVisits', 'visitors'), null, null, $config['ga.start'], $config['ga.end']);
         $return = array();
         $totalvisits = $ga->getVisits();
         $totalvisits = $totalvisits === '' ? JText::_('RSSEO_NOT_AVAILABLE') : $totalvisits;
         $uniquevisits = $ga->getVisitors();
         $uniquevisits = $uniquevisits === '' ? JText::_('RSSEO_NOT_AVAILABLE') : $uniquevisits;
         $totalpageviews = $ga->getPageviews();
         $totalpageviews = $totalpageviews === '' ? JText::_('RSSEO_NOT_AVAILABLE') : $totalpageviews;
         $avgpageviews = $ga->getPageviewsPerVisit();
         $avgpageviews = $avgpageviews === '' ? JText::_('RSSEO_NOT_AVAILABLE') : number_format($avgpageviews, 2);
         $timeonsite = $ga->getAvgTimeOnSite();
         $timeonsite = $timeonsite === '' ? JText::_('RSSEO_NOT_AVAILABLE') : $this->convertseconds(number_format($timeonsite, 0));
         $bouncerate = $ga->getVisitBounceRate();
         $bouncerate = $bouncerate === '' ? JText::_('RSSEO_NOT_AVAILABLE') : number_format($bouncerate, 2) . ' %';
         $newvisits = $ga->getPercentNewVisits();
         $newvisits = $newvisits === '' ? JText::_('RSSEO_NOT_AVAILABLE') : number_format($newvisits, 2) . ' %';
         $obj1 = new stdClass();
         $obj2 = new stdClass();
         $obj3 = new stdClass();
         $obj4 = new stdClass();
         $obj5 = new stdClass();
         $obj6 = new stdClass();
         $obj7 = new stdClass();
         $obj1->title = JText::_('RSSEO_GA_GENERAL_TOTALVISIORS');
         $obj4->title = JText::_('RSSEO_GA_GENERAL_AVGPAGEVIEWS');
         $obj1->value = $totalvisits;
         $obj4->value = $avgpageviews;
         $obj1->descr = JText::_('RSSEO_GA_GENERAL_TOTALVISIORS_DESC');
         $obj4->descr = JText::_('RSSEO_GA_GENERAL_AVGPAGEVIEWS_DESC');
         $obj2->title = JText::_('RSSEO_GA_GENERAL_UNIQUEVISITS');
         $obj5->title = JText::_('RSSEO_GA_GENERAL_TIMEONSITE');
         $obj2->value = $uniquevisits;
         $obj5->value = $timeonsite;
         $obj2->descr = JText::_('RSSEO_GA_GENERAL_UNIQUEVISITS_DESC');
         $obj5->descr = JText::_('RSSEO_GA_GENERAL_TIMEONSITE_DESC');
         $obj3->title = JText::_('RSSEO_GA_GENERAL_TOTALPAGEVIEWS');
         $obj6->title = JText::_('RSSEO_GA_GENERAL_BOUNCERATE');
         $obj3->value = $totalpageviews;
         $obj6->value = $bouncerate;
         $obj3->descr = JText::_('RSSEO_GA_GENERAL_TOTALPAGEVIEWS_DESC');
         $obj6->descr = JText::_('RSSEO_GA_GENERAL_BOUNCERATE_DESC');
         $obj7->title = JText::_('RSSEO_GA_GENERAL_NEWVISITS');
         $obj7->value = $newvisits;
         $obj7->descr = JText::_('RSSEO_GA_GENERAL_NEWVISITS_DESC');
         $return[] = $obj1;
         $return[] = $obj2;
         $return[] = $obj3;
         $return[] = $obj4;
         $return[] = $obj5;
         $return[] = $obj6;
         $return[] = $obj7;
         return $return;
     } catch (Exception $e) {
         return $e->getMessage();
     }
 }
Exemplo n.º 3
0
		</table>
		
		<table>
		<tr>
		  <th>Rows Returned</th>
		  <td><?php 
echo $ga->getTotalResults();
?>
</td>
		</tr>
		<tr>
		</tr>
		<tr>
		  <th>Total Visits</th>
		  <td><?php 
echo $ga->getVisitors();
?>
</td>
		</tr>
		<tr>
		</tr>
		<tr>
		  <th>Results Updated</th>
		  <td><?php 
echo $ga->getUpdated();
?>
</td>
		</tr>
		<tr>
			<th>Data Range: </th><td><?php 
echo $ga->getstartDate();