SAAS-174: Ability to add Google Analytics to the demo instance

- done
This commit is contained in:
James 2012-01-30 16:28:27 -05:00
parent fd92f7ba2f
commit c5f3e40397
6 changed files with 24 additions and 0 deletions

View File

@ -62,6 +62,8 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
protected function _initHeadScript()
{
global $CC_CONFIG;
$view = $this->getResource('view');
$baseUrl = Zend_Controller_Front::getInstance()->getBaseUrl();
$baseDir = dirname($_SERVER['SCRIPT_FILENAME']);
@ -86,6 +88,23 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
$view->headScript()->appendScript("var livechat_client_id = '$client_id';");
$view->headScript()->appendFile($baseUrl . '/js/airtime/common/livechat.js?'.filemtime($baseDir.'/js/airtime/common/livechat.js'), 'text/javascript');
}
if(isset($CC_CONFIG['demo']) && $CC_CONFIG['demo'] == 1){
// since we need to append google analytic code right before </head> we can't use appendFile function
// we will just store raw html into some variable
$view->google_analytics = "<script type=\"text/javascript\">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-28765064-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
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>";
}
}
protected function _initViewHelpers()

View File

@ -5,6 +5,7 @@
<title>Live stream</title>
<?php echo $this->headScript() ?>
<?php echo $this->headLink() ?>
<?php echo isset($this->google_analytics)?$this->google_analytics:"" ?>
</head>
<body>
<div id="content"><?php echo $this->layout()->content ?></div>

View File

@ -5,6 +5,7 @@
<?php echo $this->headTitle() ?>
<?php echo $this->headScript() ?>
<?php echo $this->headLink() ?>
<?php echo isset($this->google_analytics)?$this->google_analytics:"" ?>
</head>
<body>

View File

@ -5,6 +5,7 @@
<?php echo $this->headTitle() ?>
<?php echo $this->headScript() ?>
<?php echo $this->headLink() ?>
<?php echo isset($this->google_analytics)?$this->google_analytics:"" ?>
</head>
<body>

View File

@ -5,6 +5,7 @@
<?php echo $this->headTitle() ?>
<?php echo $this->headScript() ?>
<?php echo $this->headLink() ?>
<?php echo isset($this->google_analytics)?$this->google_analytics:"" ?>
</head>
<body>

View File

@ -5,6 +5,7 @@
<?php echo $this->headTitle() ?>
<?php echo $this->headScript() ?>
<?php echo $this->headLink() ?>
<?php echo isset($this->google_analytics)?$this->google_analytics:"" ?>
</head>
<body>
<div id="nowplayingbar"><?php echo $this->partial('partialviews/header.phtml', array("user" => $this->loggedInAs())) ?></div>