#
# put this in an .htaccess to substitue all your closing </html> tags with
# the google analytics js code preceding a new closing </html> tag.
#
# by doing so you can apply google analytics to a billion html files at once
# without editing - plus any new files will automatically hook into analytics
#
# you'll also need this in your httpd.conf
#
# LoadModule substitute_module libexec/apache2/mod_substitute.so
#
# see http://httpd.apache.org/docs/2.2/mod/mod_substitute.html for details
#
AddOutputFilterByType SUBSTITUTE text/html
Substitute "s!((?:\<\s*/html\s*\>\s*)\z)!\
\
\
<script type=\"text/javascript\">\
var gaJsHost = ((\"https:\" == document.location.protocol) ? \"https://ssl.\" : \"http://www.\");\
document.write(unescape(\"%3Cscript src='\" + gaJsHost + \"google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E\"));\
</script>\
\
<script type=\"text/javascript\">\
var pageTracker = _gat._getTracker(\"YOUR_GOOGLE_ANALYTICS_CODE\");\
pageTracker._initData();\
pageTracker._trackPageview();\
</script>\
\
</html>\
\
!i"