protected function __construct() { // Initilize GA Tracker $this->tracker = new ApiLib\Tracker(Config::trackingId(), Config::domain()); // Assemble Visitor information // (could also get unserialized from database) $visitor = new ApiLib\Visitor(); if (isset($_SERVER['REMOTE_ADDR'])) { $visitor->setIpAddress($_SERVER['REMOTE_ADDR']); } if (isset($_SERVER['HTTP_USER_AGENT'])) { $visitor->setUserAgent($_SERVER['HTTP_USER_AGENT']); } $visitor->setScreenResolution('1024x768'); $this->visitor = $visitor; // Assemble Session information // (could also get unserialized from PHP session) $session = new ApiLib\Session(); $this->session = $session; }
public static function ipBeforeController() { $trackingId = Config::trackingId(); if ($trackingId == 'UA-00000000-0' || empty($trackingId)) { return; } $domain = Config::domain(); $script = ipView('view/script.php', compact('trackingId', 'domain'))->render(); ipAddJsContent('GoogleAnalaytcs', $script); if (!empty($_SESSION['GoogleAnalytics']['trackPageview']) && is_array($_SESSION['GoogleAnalytics']['trackPageview'])) { foreach ($_SESSION['GoogleAnalytics']['trackPageview'] as $key => $path) { $script = ipView('view/pageview.php', array('path' => $path))->render(); ipAddJsContent('GoogleAnalaytics_pageview_' . $key, $script); } } if (!empty($_SESSION['GoogleAnalytics']['trackEvent']) && is_array($_SESSION['GoogleAnalytics']['trackEvent'])) { foreach ($_SESSION['GoogleAnalytics']['trackEvent'] as $key => $params) { $script = ipView('view/event.php', $params)->render(); ipAddJsContent('GoogleAnalaytics_event_' . $key, $script); } } }