Welcome, Guest. [ Log In ]
Question   Setting up a graphical counter on your web site.
Search KBase

Related Links:
· How do I change the number on my counter?

Top 4 in this Area:
1. What kind of canned scripts do you have?
2. Setting up a graphical counter on your web site.
3. Example of how to set up a counter
4. How do I change the number on my counter?

Setting up a graphical counter on your web site.
I would like to place a counter on my web site. How do I do this?

One of our most popular "canned" CGI scripts is our web based counter, which allows you to keep a running 'count' on your web page of all the people who have accessed it (since the counter was installed). Our counters are available to all DreamHost customers. You can install as many as you'd like, anywhere on your site, all at no cost!

To put a counter on your page, you will need to embed the following somewhere within your page's code:

      <IMG SRC="http://counter.dreamhost.com/cgi-bin/Count.cgi?df=sample.dat&dd=A&istrip=T&pad=F&ft=0" ALT="">

But wait! Don't do it yet! You need to customize the code first!

  1. Counter Data File

    The first thing you will need to do is create a unique name for your counter's data file. In the code snippet above, replace 'sample.dat' with a unique name for your data file, ending in '.dat' - we suggest something like 'username_count.dat', instead replacing 'username' with your own username. Thus, the code should look something like this:

    <img SRC="http://counter.dreamhost.com/cgi-bin/Count.cgi?df=my_data_file.dat&dd=A&istrip=T&pad=F&ft=0" ALT="">

  2. Choosing A Counter Font

    Our counter allows you to specify one of several different fonts, so you can pick one that matches your site's look and feel. To do so, simply change the letter 'A' in the counter image HTML given above to match the name given with one of the following counter fonts (remember, upper and lower case letters are different - 'A' is not the same as 'a').

    To view our selection of counter fonts, go here:


    Thus, if you chose the counter called 'visitation,' the finished code you embed in your html page should look something like this:

    <IMG SRC="http://counter.dreamhost.com/cgi-bin/Count.cgi?df=my_data_file.dat&dd=visitation&istrip=T&pad=F&ft=0" ALT="">

Last updated: Jan 03, 2002.

User Post (2005-02-13 01:14:34 by smorocho)
Please see this example if you are still confused:
User Post (2004-01-22 05:39:34 by jclark)
As it is, the counter code creates something like 23 errors when trying to validate your page as XHTML 1.0 Transitional. The earlier suggestion, about replacing the ampersands with the HTML code string worked like a charm. The counter still works, and it cut my list of errors in half (I'm still working on the rest).
User Post (2003-10-13 15:23:02 by luciano)
If you want your page with any Count.cgi code to validate as proper XHTML
you might want to replace the & in the count code string with (the ampersand symbol: & amp ;) <pre>& amp ;<pre>

This should get rid of the crazy slew of XHTML errors that occur when using a counter in XHTML.
User Post (2003-09-18 13:24:44 by valeriba)
It is imperative that the .dat file name be double-barrelled. For instance, john.dat will NOT work, it has to be john-doe.dat
User Post (2003-05-04 13:13:37 by brandy)
great link! thanks!
User Post (2002-06-04 15:49:38 by manchineel)
Lots of other counter tricks can be found here.