# HG changeset patch # User Nathan Phillip Brink # Date 2010-10-10 17:01:18 # Node ID d6ed1e1daa85be5d7e21912e45430ae7709a2b79 # Parent 82803f4e0e6a78faef69a75b9956301d8855f417 Generalized and configurable Google Analytics tracking. diff --git a/inc/class.page.php b/inc/class.page.php --- a/inc/class.page.php +++ b/inc/class.page.php @@ -5,7 +5,10 @@ * make a new include file like doconfig.inc but maybe that'll make * sense soon. */ +/* defaults */ $clean_urls = FALSE; +$ga_trackers = array(); + $config_inc = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'config.inc'; if (file_exists($config_inc)) require_once($config_inc); @@ -26,15 +29,10 @@ class page // Scripts and styles private $headCode = array(); - /* the inclusion of ga.js is augmented in __construct(). */ - private $trackingcode = ' - '; // Google analytics ga.js tracking code + /* + * Google analytics ga.js tracking code. Expanded in __construct(). + */ + private $trackingcode = ''; private $pagetitle = ''; // Title of page private $scripts = array(); // Scripts to include on page @@ -44,6 +42,8 @@ class page public function __construct($ntitle, $nscripts = array(), $immediate = TRUE) { + global $ga_trackers; + require_once('school.inc'); // Scripts and styles available to include @@ -67,11 +67,29 @@ class page header('Content-type: application/xhtml+xml'); } - $ga_www = 'http://www.'; - if ($_SERVER['SERVER_PORT'] != 80) - $ga_www = 'https://ssl.'; - $this->trackingcode = '\n"; + } self::session_start(); if($immediate diff --git a/inc/config.inc.example b/inc/config.inc.example --- a/inc/config.inc.example +++ b/inc/config.inc.example @@ -26,3 +26,13 @@ * understood ../.htaccess.example and copied it to ../.htaccess . */ /* $clean_urls = FALSE; */ + +/** + * \brief + * List of Google Analytics trackers to enable. Default: empty list. + * + * Set this to an array of Google Analytics tracker IDs if you want to + * analyze access to your slate_permutate installation. + */ +/* $ga_trackers = array(); */ +/* $ga_trackers = array('UA-XXXXXXXX-1'); */