--- a/include/common-template.inc.php +++ b/include/common-template.inc.php @@ -129,23 +129,14 @@ </script> "; } - echo ' + if (isAnalyticsOn()) echo ' <script type="text/javascript">'." var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-22173039-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></head>".' +</script>"; +echo '</head> <body> <div id="skip"> <a href="#maincontent">Skip to content</a> @@ -176,7 +167,15 @@ } echo '<div id="footer"><a href="about.php">About/Contact Us</a> <a href="feedback.php">Feedback/Bug Report</a></a>'; echo '</div>'; - if (!isDebug()) { + if (isAnalyticsOn()) { + echo "<script> (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); + })();"; $googleAnalyticsImageUrl = googleAnalyticsGetImageUrl(); echo '<img src="' . $googleAnalyticsImageUrl . '" />'; } @@ -219,5 +218,10 @@ </form> </div></div>'; } +function trackEvent($category, $action, $label = "", $value = -1) { + if (isAnalyticsOn()) { + echo "<script> _gaq.push(['_trackEvent', $category, $action".($label != "" ? ", $label" : "").($value != -1 ? ", $value" : "")."]);"; + } +} ?>