adding analytics code to php & html static pages

Discussion in 'HTML & Website Design' started by theultimatepublishing, Feb 19, 2008.

  1. #1
    I came across this article on how to add analytics code to php static pages:
    http://www.google.com/support/googleanalytics/bin/answer.py?answer=55504&topic=10981

    This is a good idea, in case they change the code in future, we just have to change one page rather than having to manually edit many static pages. Now I'm stuck with many static html pages with the old analytics code & I gotta manually change all of them..... bad mistake.

    I wonder if I can add the footer code on html pages instead of php pages. Here's another article that shows how it can be done:
    http://msdn2.microsoft.com/en-us/library/aa140051.aspx

    What do you think?
     
    theultimatepublishing, Feb 19, 2008 IP
  2. Cri2T

    Cri2T Peon

    Messages:
    104
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    The first article is pretty good, the second one is useless if you already know PHP (because SSI's are one of the first things you learn about when you learn PHP)

    Although, I'm sure someone will find it very useful.
     
    Cri2T, Feb 19, 2008 IP
  3. theultimatepublishing

    theultimatepublishing Peon

    Messages:
    207
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks. Anyway does it work if I add an <!--#include virtual="footer.html"--> on all my static pages & footer.html is where I place my analytics code.
     
    theultimatepublishing, Feb 19, 2008 IP
  4. Cri2T

    Cri2T Peon

    Messages:
    104
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #4
    It should. Try it out and see.
     
    Cri2T, Feb 19, 2008 IP
  5. wd_2k6

    wd_2k6 Peon

    Messages:
    1,740
    Likes Received:
    54
    Best Answers:
    0
    Trophy Points:
    0
    #5
    at the bottom of your html just use the same code:

    <?php include("xx.php"); ?>

    where "xx.php" is the file containing your analytics code
     
    wd_2k6, Feb 19, 2008 IP
  6. theultimatepublishing

    theultimatepublishing Peon

    Messages:
    207
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #6
    This will only work on php files, I want know how to do it on html files.

    <!--#include virtual="footer.html"-->

    I wonder if it will work on both php & html files. Usually I start with html pages then I save them as php, since I'm using FrontPage.
     
    theultimatepublishing, Feb 19, 2008 IP
  7. webrehash

    webrehash Peon

    Messages:
    163
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #7
    The analytics code should be the same on all your pages (I'm assuming), can you just do a find/replace across all your static pages and update the code?
     
    webrehash, Feb 20, 2008 IP