latest   5 entries tagged 'unix': 1-5
permalink 2006-04-05  programming google unix
edit  
Do you need to add the tracking code block to every webpage on your site? Depending on the nature of your site and the tools you use to publish webpages this can be as simple as filling in the blank in one form or as daunting as the prospect of editing every single file the site. My site has been around for a while and over the years I have used a variety of techniques to publish pages depending on my current skill level at the time. So in my case adding tracking code to every page ranges from dealing with plain html pages written with vi to the results of content generating techniques based on lMaker, mySQL or php.

For this example we imagine the worst case, a site of plain html files that have to be handled individually and we have to insert that snippet of tracking code into each file just before the </head> tag. The plan is to use the find command to walk us through the website one file at a time and then use the ed command to insert our code where we want it to appear.

In the top level directory of the website we need to make three small files to help us out. First we copy our tracking code into a file:

    tracking.txt:
    <script src="http://www.google-analytics.com/urchin.js"
    type="text/javascript">
    </script>
    <script type="text/javascript">
    _uacct = "UA-######-1";
    urchinTracker();
    </script>
    
Note that you need to replace the UA-######-1 with your own website's tracking code.

Next we will need a set of instructions for ed:

    ed.cmd
    /<\/HEAD>
    -1r tracking.txt
    w
    q
    
Those four little lines will save us a lot of work. The line /<\/HEAD> tells ed to go the first occurence of a line containing the closing </head> tag. (That is a case-sensitive search so if you need to, change it to /<\/head> instead.) The next line, -1r tracking.txt tells ed to read and insert the contents of tracking.txt above the current line. The 'w' command writes out the file and 'q' is for 'quit'.

Finally we need a shell script to pull it all together for us:

    install_tracking.sh
    #!/bin/sh
    
    for FILE in `find . -name "*.html" -print`
    do
        ed $FILE < ed.cmd
    done
    
At the Unix command prompt enter "sh install_tracking.sh". That's what I did and now my site is ready to reap the benefits of all those cool reports available from Google Analytics.
permalink 2004-02-17  internet unix linux
edit  
pedigree & comparison to Linux, GNU
permalink 2004-02-17  unix wishlist
edit  
the Rover ooperating system
permalink 2004-02-17  unix
edit  
lots of solutions to UNIX problems
permalink 2003-05-16  programming funny microsoft unix
edit  
echo Mhbqnrnes Stbjr | tr [a-y] [b-z]
    Porting from Win 16 to Win 32
    #include "win31.h"
    #include "win95.h"
    #include "evenmore.h"
    #include "oldstuff.h"
    #include "billrulz.h"
    #include "monopoly.h"
    #define INSTALL = HARD
    
    char make_prog_look_big[1600000];
    void main()
    {
      while(!CRASHED)
      {
        display_copyright_message();
        display_bill_rules_message();
        do_nothing_loop();
        if (first_time_installation)
        {
          make_50_megabyte_swapfile();
          do_nothing_loop();
          totally_screw_up_HPFS_file_system();
          search_and_destroy_the_rest_of_OS/2();
          disable_Netscape();
          disable_RealPlayer();
          disable_Corel_Products();
          hang_system();
        }
    
        write_something(anything);
        display_copyright_message();
        do_nothing_loop();
        do_some_stuff();
    
        if (still_not_crashed)
        {
          display_copyright_message();
          do_nothing_loop();
          basically_run_windows_3.1();
          do_nothing_loop();
          do_nothing_loop();
        }
      }
    
      if (detect_cache())
        disable_cache();
    
      if (fast_cpu())
      {
        set_wait_states(lots);
        set_mouse(speed, very_slow);
        set_mouse(action, jumpy);
        set_mouse(reaction, sometimes);
      }
    
      /* printf("Welcome to Windows 3.11"); */
      /* printf("Welcome to Windows 95"); */
      printf("Welcome to Windows 98");
      if (system_ok())
        crash(to_dos_prompt)
      else
        system_memory = open("a:\swp0001.swp", O_CREATE);
    
      while(something)
      {
        sleep(5);
        get_user_input();
        sleep(5);
        act_on_user_input();
        sleep(5);
      }
      create_general_protection_fault();
    }
    

tags: larger lettering indicates there are more entries with that tag
9-11
adsense
bob_hope
book
bush
ching
computers
cool
fire
firefox
flood
freedom
funny
gadget
games
gianna
google
google_analytics
harry_potter
history
html
ibm
internet
iraq
jack_black
javascript
jobs
johnny_cash
keeshan
legal
linux
maps
marilyn_vos_savant
microsoft
movie
mukhtar_mai
music
open_source
outsourcing
pair.com
people
photo
picasa
politics
programming
reference
sco
security
site
spam
spyware
star_trek
star_wars
thumbly
time
tivo
travel
trivia
unix
usability
wishlist
Add to Google
 
Web this blog
[static pages] © 2010 Michael Thompson