-
-
Save zenman/5495387 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//hostname based google code, only run if on live site - Tom Horak | |
//placed right before closing body tag according to google best practice: http://support.google.com/googleanalytics/bin/answer.py?hl=en&answer=55488 | |
//moved to right before closing head tag per SEOverflow 05/25/12 | |
$hostname = $_SERVER['HTTP_HOST']; //dev.zenman.com | localhost | Live server | etc.. | |
switch ($hostname) { | |
case 'localhost': //do nothing | |
//echo '<!-- no google analytics code -->'; | |
break; | |
case 'localhost:8888': //do nothing | |
//echo '<!-- no google analytics code -->'; | |
break; | |
case 'dev1.zenman.com': //do nothing | |
//echo '<!-- no google analytics code -->'; | |
break; | |
case 'test1.zenman.com': //do nothing | |
//echo '<!-- no google analytics code -->'; | |
break; | |
case 'stage1.zenman.com': //mimic live environment... | |
?> | |
<script type="text/javascript"> | |
var _gaq = _gaq || []; _gaq.push(['_setAccount', 'GA CODE HEREEERERERERERE']); _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> | |
<?php | |
break; | |
default: //this is what you get on live server | |
?> | |
<script type="text/javascript"> | |
var _gaq = _gaq || []; _gaq.push(['_setAccount', 'GA CODE HEREEERERERERERE']); _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> | |
<?php | |
break; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment