. * * @category Plugin * @package StatusNet * @author Evan Prodromou * @copyright 2008 StatusNet, Inc. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ */ if (!defined('STATUSNET')) { exit(1); } /** * Plugin to use Google Analytics * * This plugin will spoot out the correct JavaScript spell to invoke Google Analytics on a page. * * Note that Google Analytics is not compatible with the Franklin Street Statement; consider using * Piwik (http://www.piwik.org/) instead! * * @category Plugin * @package StatusNet * @author Evan Prodromou * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ * * @see Event */ class GoogleAnalyticsPlugin extends Plugin { var $code; var $domain; const VERSION = '0.2'; function __construct($code=null) { if (!empty($code)) { global $config; $config['googleanalytics']['code'] = $code; } parent::__construct(); } function onEndShowScripts(Action $action) { $code = common_config('googleanalytics', 'code'); if (empty($code)) { $code = $this->code; } $domain = common_config('googleanalytics', 'domain'); if (empty($domain)) { $domain = $this->domain; } $js = <<inlineScript($js); } function onPluginVersion(array &$versions) { $versions[] = array('name' => 'GoogleAnalytics', 'version' => self::VERSION, 'author' => 'Evan Prodromou', 'homepage' => 'http://status.net/wiki/Plugin:GoogleAnalytics', 'rawdescription' => // TRANS: Plugin description. _m('Use Google Analytics'. ' to track web access.')); return true; } }