Bug 441991 - Remove Google Analytics from site_login
Change-Id: I634300445221860f600b3a7ef321a6685a320260
Signed-off-by: Christopher Guindon <chris.guindon@eclipse.org>
diff --git a/eclipse.org-common/system/app.class.php b/eclipse.org-common/system/app.class.php
index a41b691..103cefe 100644
--- a/eclipse.org-common/system/app.class.php
+++ b/eclipse.org-common/system/app.class.php
@@ -493,66 +493,34 @@
echo $html;
- #first lets insert the sitewide Analytics
- $this->googleJavaScript = <<<EOHTML
- <script type="text/javascript">
+ $gaCode = $this->projectGoogleAnalyticsCode;
+ if (!is_null($gaCode)) {
+ $gaCode = ($gaCode == "") ? 'UA-910670-2' : $gaCode;
+ #first lets insert the sitewide Analytics
+ $this->googleJavaScript = <<<EOHTML
+ <script type="text/javascript">
- var _gaq = _gaq || [];
- _gaq.push(['_setAccount', 'UA-910670-2']);
- _gaq.push(['_trackPageview']);
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', '$gaCode']);
+ _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);
- })();
+ (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>
+ </script>
EOHTML;
- #Now let Check to see if the project is also providing a GA code and include that if they are.
- if ($this->projectGoogleAnalyticsCode != "")
- {
- $gaCode = $this->projectGoogleAnalyticsCode;
- $this->googleJavaScript .= <<<EOHTML
-
- <script type="text/javascript">
-
- var _gaq = _gaq || [];
- _gaq.push(['_setAccount', '$gaCode']);
- _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>
-EOHTML;
}
if ($theme != "solstice") {
echo $this->googleJavaScript;
}
+
$google_javascript = $this->googleJavaScript;
include($this->getFooterPath($theme));
-
- # OPT1:$starttime = microtime();
- # OPT1:$html = ob_get_contents();
- # OPT1:ob_end_clean();
-
- # OPT1:$stripped_html = $html;
- # OPT1:$stripped_html = preg_replace("/^\s*/", "", $stripped_html);
- # OPT1:$stripped_html = preg_replace("/\s{2,}/", " ", $stripped_html);
- # OPT1:$stripped_html = preg_replace("/^\t*/", "", $stripped_html);
- # OPT1:$stripped_html = preg_replace("/\n/", "", $stripped_html);
- # OPT1:$stripped_html = preg_replace("/>\s</", "><", $stripped_html);
- # $stripped_html = preg_replace("/<!--.*-->/", "", $stripped_html);
- # OPT1:$endtime = microtime();
-
- # OPT1:echo "<!-- unstripped: " . strlen($html) . " bytes/ stripped: " . strlen($stripped_html) . "bytes - " . sprintf("%.2f", strlen($stripped_html) / strlen($html)) . " Bytes saved: " . (strlen($html) - strlen($stripped_html)) . " Time: " . ($endtime - $starttime) . " -->";
- # echo $stripped_html;
}
function AddExtraHtmlHeader( $string ) {
@@ -1191,6 +1159,14 @@
return $strn;
}
+ /**
+ * Set Google Analytics Tracking code
+ *
+ * @param string OR Null $gaUniqueID
+ *
+ * Setting $gaUniqueID to NULL will remove Google Analytics
+ * from the page.
+ */
function setGoogleAnalyticsTrackingCode($gaUniqueID) {
$this->projectGoogleAnalyticsCode = $gaUniqueID;
}
diff --git a/site_login/index.php b/site_login/index.php
index 1faf5e6..5a41f7b 100755
--- a/site_login/index.php
+++ b/site_login/index.php
@@ -229,4 +229,5 @@
include($includefile);
# Generate the web page
+ $App->setGoogleAnalyticsTrackingCode(NULL);
$App->generatePage($theme, $Menu, $Nav, $pageAuthor, $pageKeywords, $pageTitle, $html);
diff --git a/site_login/logout.php b/site_login/logout.php
index 56f709f..2680b54 100644
--- a/site_login/logout.php
+++ b/site_login/logout.php
@@ -61,4 +61,5 @@
$App->AddExtraHtmlHeader('<meta http-equiv="refresh" content="2;url=' . $redirect . '"> ');
+ $App->setGoogleAnalyticsTrackingCode(NULL);
$App->generatePage($theme, $Menu, NULL, $pageAuthor, $pageKeywords, $pageTitle, $html);
diff --git a/site_login/myaccount.php b/site_login/myaccount.php
index 733f9e2..a1b9fd2 100755
--- a/site_login/myaccount.php
+++ b/site_login/myaccount.php
@@ -202,5 +202,6 @@
include($includefile);
# Generate the web page
//$Nav->addCustomNav("Friends of Eclipse", "http://www.eclipse.org/donate/", "_self", 0);
+ $App->setGoogleAnalyticsTrackingCode(NULL);
$App->generatePage($theme, $Menu, $Nav, $pageAuthor, $pageKeywords, $pageTitle, $html);
?>
\ No newline at end of file