<?php // session_start for caching session_start(); require 'analytics.class.php'; try { // construct the class $oAnalytics = new analytics('[username]', '[password]'); // set it up to use caching $oAnalytics->useCache(); $oAnalytics->setProfileByName('[Google analytics accountname]'); // or $oAnalytics->setProfileById('ga:123456'); // set the date range $oAnalytics->setMonth(date('n'), date('Y')); // or $oAnalytics->setDateRange('YYYY-MM-DD', 'YYYY-MM-DD'); echo '<pre>'; // print out visitors for given period print_r($oAnalytics->getVisitors()); // print out pageviews for given period print_r($oAnalytics->getPageviews()); // use dimensions and metrics for output // see: http://code.google.com/intl/nl/apis/analytics/docs/gdata/gdataReferenceDimensionsMetrics.html print_r($oAnalytics->getData(array('dimensions' => 'ga:keyword', 'metrics' => 'ga:visits', 'sort' => 'ga:keyword'))); } catch (Exception $e) { echo 'Caught exception: ' . $e->getMessage(); }
including the charts class for displaying user activity for the past week. */ include "../" . MODS_DIRECTORY . "/charts/FusionCharts_Gen.php"; include "../" . USER_DIRECTORY . "/header.php"; $js = "<script language=\"javascript\" src=\"{$website}/" . JS_DIRECTORY . "/FusionCharts.js\"></script>"; subheader(_("Statistics"), null, $js); if ($sesslife == true) { if ($is_admin == 1) { echo "<div class=\"page-header\"><h1>" . _("Statistics") . "</h1></div>"; echo "<h6>" . _("Options") . " : <a href=\"{$website}/" . ADMIN_DIRECTORY . "/settings#/analytics\">" . _("Analytics Settings") . "</a></h6><br/>"; echo "<ul class=\"breadcrumb\">\n\t\t<li><a href=\"{$website}/" . ADMIN_DIRECTORY . "/settings\">" . _("Home") . "</a> <span class=\"divider\">/</span></li>\n\t\t<li class=\"active\">" . _("Statistics") . "</li>\n\t\t</ul>"; if (!empty($_setting['google_id']) && !empty($_setting['google_password']) && !empty($_setting['site_id'])) { echo "<div class=\"alert\">" . _("Google ID") . " : <strong>{$_setting['google_id']}</strong> " . _("Site ID") . " : <strong>{$_setting['site_id']}</strong></div>"; $analytics = new analytics($_setting['google_id'], $_setting['google_password']); $analytics->setProfileById("ga:" . $_setting['site_id']); $analytics->setMonth(date("n"), date("Y")); $month = date("M"); $visitors = $analytics->getVisitors(); $total = count($visitors); $basic = 0; $count = "01"; while ($count < $total + 1) { $arrData[$basic][0] = $count; $arrData[$basic][1] = $visitors[$count]; $count++; $basic++; if ($count < 10) { $count = "0" . $count; } } $FC = new FusionCharts("Column3D", "800", "300");
$aProfileKeys = array_keys($aProfiles); // set the profile tot the first account $oAnalytics->setProfileById($aProfileKeys[0]); $iSelectedMonth = date('n'); } if (isset($_POST['profileId'])){ // change profileId $oAnalytics->setProfileById($_POST['profileId']); } if (isset($_POST['month'])){ // change month $iSelectedMonth = $_POST['month']; } // set the month $oAnalytics->setMonth($iSelectedMonth, date('Y')); // alternativly set a date range: // $oAnalytics->setDateRange('YYYY-MM-DD', 'YYYY-MM-DD'); /** * Basic html table for displaying graphs * * @param array $aData */ function graph($aData){ $iMax = max($aData); if ($iMax == 0){ echo 'No data'; return;