From c709e12440b425f56f887fd67bc176afb19710e2 Mon Sep 17 00:00:00 2001 From: DrudexSoftware Date: Thu, 7 Feb 2013 21:41:01 +0100 Subject: [PATCH] Google Analytics Integration allows users to optionally use google analytics tracking in shimmie by simply entring the analytics id in the board config. --- ext/google_analytics/main.php | 43 +++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 ext/google_analytics/main.php diff --git a/ext/google_analytics/main.php b/ext/google_analytics/main.php new file mode 100644 index 00000000..628be24e --- /dev/null +++ b/ext/google_analytics/main.php @@ -0,0 +1,43 @@ + + * Link: http://drudexsoftware.com + * License: GPLv2 + * Description: Integrates Google Analytics tracking + * Documentation: + * User has to enter their Google Analytics ID in the Board Config to use this extention. + */ +class google_analytics extends Extension { + # Add analytics to config + public function onSetupBuilding(SetupBuildingEvent $event) { + global $config; + + $sb = new SetupBlock("Google Analytics"); + $sb->add_text_option("google_analytics_id", "Analytics ID: "); + $sb->add_label("
(eg. UA-xxxxxxxx-x)"); + + $event->panel->add_block($sb); + } + + # Load Analytics tracking code on page request + public function onPageRequest(PageRequestEvent $event) { + global $config; + global $page; + + $google_analytics_id = $config->get_string('google_analytics_id',''); + if (stristr($google_analytics_id, "UA-") && $google_analytics_id != "") + { + $page->add_html_header(""); + } + } +} +?>