Exemplo n.º 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
         }
     }
 }
Exemplo n.º 2
0
 /**
  * @link http://code.google.com/p/gaforflash/source/browse/trunk/src/com/google/analytics/v4/Tracker.as#585
  * @return string
  */
 protected function generateDomainHash()
 {
     $hash = 1;
     if ($this->tracker->getAllowHash()) {
         $hash = Util::generateHash($this->tracker->getDomainName());
     }
     return $hash;
 }
Exemplo n.º 3
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);
     }
 }
Exemplo n.º 4
0
 /**
  * Will extract information for the "trackCount" and "startTime"
  * properties from the given "__utmb" cookie value.
  * 
  * @see Internals\ParameterHolder::$__utmb
  * @see Internals\Request\Request::buildCookieParameters()
  * @param string $value
  * @return $this
  */
 public function fromUtmb($value)
 {
     $parts = explode('.', $value);
     if (count($parts) != 4) {
         Tracker::_raiseError('The given "__utmb" cookie value is invalid.', __METHOD__);
         return $this;
     }
     $this->setTrackCount($parts[1]);
     $this->setStartTime(new DateTime('@' . $parts[3]));
     // Allow chaining
     return $this;
 }
Exemplo n.º 5
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);
}
Exemplo n.º 6
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);
    }
}
Exemplo n.º 7
0
 /**
  * @see generateUniqueId
  * @param int $value
  */
 public function setUniqueId($value)
 {
     if ($value < 0 || $value > 0x7fffffff) {
         Tracker::_raiseError('Visitor unique ID has to be a 32-bit integer between 0 and ' . 0x7fffffff . '.', __METHOD__);
     }
     $this->uniqueId = (int) $value;
 }
Exemplo n.º 8
0
 /**
  * @param int $scope
  */
 public function setScope($scope)
 {
     if (!in_array($scope, array(self::SCOPE_PAGE, self::SCOPE_SESSION, self::SCOPE_VISITOR))) {
         Tracker::_raiseError('Custom Variable scope has to be one of the CustomVariable::SCOPE_* constant values.', __METHOD__);
     }
     $this->scope = (int) $scope;
 }
Exemplo n.º 9
0
$file = $_GET['file'];
// 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);
}
Exemplo n.º 10
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);
Exemplo n.º 11
0
 /**
  * @link http://code.google.com/p/gaforflash/source/browse/trunk/src/com/google/analytics/campaign/CampaignTracker.as#153
  */
 public function validate()
 {
     // NOTE: gaforflash states that id and gClickId must also be specified,
     // but that doesn't seem to be correct
     if (!$this->source) {
         Tracker::_raiseError('Campaigns need to have at least the "source" attribute defined.', __METHOD__);
     }
 }