• How to put a counter on your webpage

    For Riverland Internet users, 9 Jan 98. psid

    1. Text counter

    This counter counts hits - i.e. it increments every time the page is requested.

    Insert the following HTML into your page where you want the count to appear:
                 <!--#exec cgi="/cgi-bin/counter-nl"-->

    When the webserver processes this, it replaces this tag with the number generated by the counter CGI.


    2. Graphical counter

    counter.pl is from Matt's Script Archive, with a local fix or two applied.

    This counter counts accesses to a graphic, which will show a lower number than a hit counter. It increments each time a browser requests the graphic, which is more likely to be once per visit, while a hit counter will increment each time the visitor traverses the counter page.

    This counter can do some extra logging of visitors. These days, the logging available as part of our webhosting is better, so we're no longer recommending the counter's logging.

    Each page needs to have its own version of this CGI, otherwise the counter will update only the first time a particular visitor sees it. (i.e. someone who visited two pages on our webserver, if each used the same CGI script, would only see the number from the first page.) We charge a once-only setup fee ($22 inc GST at present) to get this running, because there's a fair amount of configuration.

    This counter CGI has the option of not showing a counter! This could be useful if you just wanted the logging. The counter could still be turned on later, when the low count number is not so embarrassing. The counter CGI returns a graphic, but it can be a single transparent pixel, or it can return a graphic that's already on your page.

    It also has the option of using any set of digits you want: at present we have three, but feel free to find your own:

    • odo
      7seg
      visitation

    New Sets of Digits

    Digitmania have lots of digits, and Yahoo has links to collections of them. This CGI expects all the digits in a set to be the same size.

    If you want new digits, download them, unzip them into a new digit directory, rename them 0.gif .. 9.gif if necessary. It's wise to look at the digits with a paint program, and if necessary save them as 16-color GIFs. Then they need to be put on the webserver.

    At present, they have to be saved as 16-color GIFs, or the CGI will put a white border at the bottom and right edge of the digits. If you're using a frame around the digits, or your page has a non-black background, this will be a problem, so make sure the digits are 16-color. A cheap fix is to not use the frame! Apparently it's something fly isn't doing right, for 256-color digits.

    Other options for the GIF produced by the CGI:

    • Frame width and color.
      You can have (or not) a frame around the digits. Specify the width in pixels, and the colour in RGB values.

      Transparent colour
      Specify the RGB values for the colour you want transparent, or None

      Interleave
      Do you want the GIF interleaved? Yes or no.

      Return a "logo"?
      The counter can return an existing graphic. Supply the URL, or "no".

    After setting up, you call the CGI from a webpage as follows:

    • <img src="/cgi-bin/counter-USER.pl">