Beispiel #1
0
 /**
  * Google analytics tracker
  *
  * @static
  * @return void
  */
 public static function analytics()
 {
     $site = Site::config('general');
     $services = Site::config('services');
     // Run analytics if a tracking code is set
     if (!empty($services->googleAnalyticsId)) {
         try {
             // Initilize GA Tracker
             $tracker = new GoogleAnalytics\Tracker($services->googleAnalyticsId, $site->fqdn);
             // Gather visitor information
             $visitor = new GoogleAnalytics\Visitor();
             $visitor->setIpAddress(Request::getClientIp());
             $visitor->setUserAgent(Request::server('HTTP_USER_AGENT'));
             // Gather session information
             $session = new GoogleAnalytics\Session();
             // Gather page information
             $path = Request::path();
             $page = new GoogleAnalytics\Page($path == '/' ? $path : "/{$path}");
             $page->setTitle($site->title);
             // Track page view
             $tracker->trackPageview($page, $session, $visitor);
         } catch (GoogleAnalytics\Exception $e) {
             // Suppress this error
         }
     }
 }
Beispiel #2
0
 /**
  * Track the request with Google Analytics.
  */
 public static function track()
 {
     if (self::$isLive) {
         // Initilize GA Tracker
         $tracker = new GoogleAnalytics\Tracker('UA-5596313-6', 'weloveiconfonts.com');
         // Assemble Visitor information
         $visitor = new GoogleAnalytics\Visitor();
         $visitor->setIpAddress($_SERVER['REMOTE_ADDR']);
         $visitor->setUserAgent($_SERVER['HTTP_USER_AGENT']);
         $visitor->setScreenResolution('1024x768');
         // Assemble Session information
         $session = new GoogleAnalytics\Session();
         // Assemble Page information
         $page = new GoogleAnalytics\Page($_SERVER['REQUEST_URI']);
         $page->setTitle('We Love Icon Fonts');
         // Track page view
         $tracker->trackPageview($page, $session, $visitor);
     }
 }
Beispiel #3
0
function ga_init($a)
{
    global $post;
    //var_dump($post->post_name);
    // Initilize GA Tracker
    $tracker = new GoogleAnalytics\Tracker(_GAT_STR, 'www.fixtures.ie');
    // Assemble Visitor information
    // (could also get unserialized from database)
    $visitor = new GoogleAnalytics\Visitor();
    $visitor->setIpAddress($_SERVER['REMOTE_ADDR']);
    $visitor->setUserAgent($_SERVER['HTTP_USER_AGENT']);
    $visitor->setScreenResolution('1024x768');
    // Assemble Session information
    // (could also get unserialized from PHP session)
    $session = new GoogleAnalytics\Session();
    // Assemble Page information
    $page = new GoogleAnalytics\Page('/' . $post->post_name);
    $page->setTitle($post->post_title);
    // Track page view
    $tracker->trackPageview($page, $session, $visitor);
}
Beispiel #4
0
 /**
  * @param \UnitedPrototype\GoogleAnalytics\Internals\ParameterHolder $p
  * @return \UnitedPrototype\GoogleAnalytics\Internals\ParameterHolder
  */
 protected function buildCampaignParameters(ParameterHolder $p)
 {
     $campaign = $this->tracker->getCampaign();
     if ($campaign) {
         $p->__utmz = $this->generateDomainHash() . '.';
         $p->__utmz .= $campaign->getCreationTime()->format('U') . '.';
         $p->__utmz .= $this->visitor->getVisitCount() . '.';
         $p->__utmz .= $campaign->getResponseCount() . '.';
         // See http://code.google.com/p/gaforflash/source/browse/trunk/src/com/google/analytics/campaign/CampaignTracker.as#236
         $data = array('utmcid' => $campaign->getId(), 'utmcsr' => $campaign->getSource(), 'utmgclid' => $campaign->getGClickId(), 'utmdclid' => $campaign->getDClickId(), 'utmccn' => $campaign->getName(), 'utmcmd' => $campaign->getMedium(), 'utmctr' => $campaign->getTerm(), 'utmcct' => $campaign->getContent());
         foreach ($data as $key => $value) {
             if ($value !== null && $value !== '') {
                 // Only spaces and pluses get escaped in gaforflash and ga.js, so we do the same
                 $p->__utmz .= $key . '=' . str_replace(array('+', ' '), '%20', $value) . static::CAMPAIGN_DELIMITER;
             }
         }
         $p->__utmz = rtrim($p->__utmz, static::CAMPAIGN_DELIMITER);
     }
     return $p;
 }
 /**
  * Get a GA visitor, if one doesn't exist build one and set it from the utma cookie
  * @return GoogleAnalytics\Visitor The visitor
  */
 public function getGAVisitor()
 {
     if (null == $this->gaVisitor) {
         $visitor = new GoogleAnalytics\Visitor();
         if (SSCookie::get('__utma')) {
             $visitor->fromUtma(SSCookie::get('__utma'));
         }
         $visitor->fromServerVar($_SERVER);
         $visitor->addSession($this->getGASession());
         $this->setGAVisitor($visitor);
     }
     return $this->gaVisitor;
 }
Beispiel #6
0
// not used now
if (!isset($_SERVER['HTTP_RANGE'])) {
    // old version
    // update_count_of_downloads($file) ;
    if (!isset($_GET['event'])) {
        $eventno = 1;
    } else {
        $eventno = $_GET['event'];
    }
    if (isset($_GET['osmandver'])) {
        $app = $_GET['osmandver'];
    } else {
        $app = 'Download ' . $_SERVER['HTTP_USER_AGENT'];
    }
    $tracker = new GoogleAnalytics\Tracker('UA-28342846-1', 'download.osmand.net');
    $visitor = new GoogleAnalytics\Visitor();
    $visitor->setIpAddress($_SERVER['REMOTE_ADDR']);
    $visitor->setUserAgent($_SERVER['HTTP_USER_AGENT']);
    $visitor->setScreenResolution('1024x768');
    // Assemble Session information
    // (could also get unserialized from PHP session)
    $session = new GoogleAnalytics\Session();
    // Assemble Page information
    $page = new GoogleAnalytics\Page('/download.php?' . $file);
    $page->setTitle('Download file ' . $file);
    // Track page view
    $tracker->trackPageview($page, $session, $visitor);
    $event = new GoogleAnalytics\Event($app, 'App', $file, $eventno);
    $tracker->trackEvent($event, $session, $visitor);
}
set_time_limit(0);
Beispiel #7
0
function leechgate_track_ga($config)
{
    try {
        // prepare GA structures
        $tracker = new GoogleAnalytics\Tracker($config['gaid'], $config['normalized_host']);
        $visitor = new GoogleAnalytics\Visitor();
        $visitor->fromServerVar($_SERVER);
        if ($config['utma_cookie']) {
            $visitor->fromUtma($config['utma_cookie']);
        }
        $session = new GoogleAnalytics\Session();
        $event = new GoogleAnalytics\Event($config['normalized_host'], $config['product'], $config['product_version']);
        $event->setNoninteraction(true);
        // track it!
        $tracker->trackEvent($event, $session, $visitor);
    } catch (Exception $e) {
        $fe = fopen('php://stderr', 'w');
        fwrite($fe, "Caught exception in leechgate_track_ga: " . $e->getMessage() . "\n");
        fclose($fe);
    }
}
Beispiel #8
0
        $g = hexdec(substr($hex, 2, 2));
        $b = hexdec(substr($hex, 4, 2));
    }
    $rgb = array($r, $g, $b);
    return $rgb;
}
function ellipsis($text)
{
    $max = 30;
    $append = '...';
    if (strlen($text) <= $max) {
        return $text;
    }
    $out = substr($text, 0, $max);
    return preg_replace('/\\w+$/', '', $out) . $append;
}
// Google Analytics
require_once $_SERVER['DOCUMENT_ROOT'] . '/php-ga/autoload.php';
use UnitedPrototype\GoogleAnalytics;
$tracker = new GoogleAnalytics\Tracker('UA-37973757-2', 'streambadge.com');
$visitor = new GoogleAnalytics\Visitor();
$visitor->setIpAddress($_SERVER['REMOTE_ADDR']);
$visitor->setUserAgent($_SERVER['HTTP_USER_AGENT']);
$session = new GoogleAnalytics\Session();
$page = new GoogleAnalytics\Page('/' . $service . '/badge.php?' . $_SERVER['QUERY_STRING'] . '-' . $_SERVER['HTTP_REFERER']);
$page->setTitle($service . '.tv (image badge)');
$tracker->trackPageview($page, $session, $visitor);
// Output to browser
header('Content-Type: image/png');
imagepng($im);
imagedestroy($im);