forked from Cavemanon/cavepaintings
PSR-2. I'm not a huge fan, but ugly consistency beats no consistency...
This commit is contained in:
@ -8,22 +8,25 @@
|
||||
* 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) {
|
||||
$sb = new SetupBlock("Google Analytics");
|
||||
$sb->add_text_option("google_analytics_id", "Analytics ID: ");
|
||||
$sb->add_label("<br>(eg. UA-xxxxxxxx-x)");
|
||||
$event->panel->add_block($sb);
|
||||
}
|
||||
class google_analytics extends Extension
|
||||
{
|
||||
# Add analytics to config
|
||||
public function onSetupBuilding(SetupBuildingEvent $event)
|
||||
{
|
||||
$sb = new SetupBlock("Google Analytics");
|
||||
$sb->add_text_option("google_analytics_id", "Analytics ID: ");
|
||||
$sb->add_label("<br>(eg. UA-xxxxxxxx-x)");
|
||||
$event->panel->add_block($sb);
|
||||
}
|
||||
|
||||
# Load Analytics tracking code on page request
|
||||
public function onPageRequest(PageRequestEvent $event) {
|
||||
global $config, $page;
|
||||
# Load Analytics tracking code on page request
|
||||
public function onPageRequest(PageRequestEvent $event)
|
||||
{
|
||||
global $config, $page;
|
||||
|
||||
$google_analytics_id = $config->get_string('google_analytics_id','');
|
||||
if (stristr($google_analytics_id, "UA-")) {
|
||||
$page->add_html_header("<script type='text/javascript'>
|
||||
$google_analytics_id = $config->get_string('google_analytics_id', '');
|
||||
if (stristr($google_analytics_id, "UA-")) {
|
||||
$page->add_html_header("<script type='text/javascript'>
|
||||
var _gaq = _gaq || [];
|
||||
_gaq.push(['_setAccount', '$google_analytics_id']);
|
||||
_gaq.push(['_trackPageview']);
|
||||
@ -32,7 +35,6 @@ class google_analytics extends Extension {
|
||||
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
||||
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
||||
})();</script>");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user