PHP Voodoo To Add Google Analytics To Static HTML Files

I host Steve Bett’s resources for trying to make sense of English spelling and promoting the sensible option of moving to a phonetic spelling. He has published so much fantastic content here!

All of the content he has published by writing into an HTML editor and then uploading it using FTP. It is awkward.

I have always been too busy to provide a better solution, but now I hope to work with him to migrate to using a Content Management System (CMS).

First step is adding some Google Analytics to all those static HTML files. This will tell us how much pain it will be if/when we change the location (URLs) of all that content and if there are some important ones that we should explicitly redirect.

I did this without touching any of the HTML files with some PHP Voodoo. PHP’s auto_prepend_file was my friend. Thank you Brajeshwar B. Oinam for Effective way to update your blog’s header scripts with some help from phpPatterns’ develop:bringing_static_html_to_life_with_php and Zend’s A Better way to Auto Prepend/Append

This entry was posted in Web. Bookmark the permalink.

4 Responses to PHP Voodoo To Add Google Analytics To Static HTML Files

  1. Meekish says:

    So what did your final .htaccess end up looking like?

  2. Lloyd says:

    ~/web/public/users/sbett]$ cat .htaccess
    AddType application/x-httpd-php .html .htm
    php_value auto_prepend_file myprepend.php

  3. Meekish says:

    Is the path for “myprepend.php” relative to the folder in which the .htaccess file resides?

  4. Lloyd says:

    Sorry, yes, myprepend.php is in sbett/

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>