So, You Want A Counter, Huh?

By Joe Burns

FYI: This tutorial refers to the use of a CGI (Common Gateway Interface) application. You will need to attach to one to make it work. Chances are your server has one. I'll explain further as I go on. You can also take a look here.

Use these links to jump around or read it all...
[Why Do You Want This Counter?] [What Is A Counter?] [The Format Of A Counter]
[Three Ways To Get A Counter] [The Best Way]
[The Next Best Way] [This Will Work, Too]

You are the person to ask me that!

     This is without a doubt the number one item people ask me about. Everyone wants a counter. Why? I don't know. My guess is because someone else has one. I don't have a lot of room to talk. I have one, too.

     If you have already attempted to surf the Net in order to find a nice easy page telling you how to put up a counter, you have probably encountered something that uses words like: Bitmap, Stadealone Daemon, Config File, and Inetd. Right? Not exactly an easy "how to."

     Here's the reason the pages are so darn technical. Counters are technical. It's a fact of Internet life. If you have already read my tutorial on Image Maps you are already familiar with the concept of a CGI application or Common Gateway Interface. This is a little program that sits deep in the guts of an Internet server and does tricks like make an Image Map work or count the number of visitors to your page.

     The highly technical pages on counters assume you have the ability to get into the guts of the server and place a CGI application. My guess is that if you're reading this, you don't have that ability. You simply want a counter on your page.

Sorry About This...

     Now here's the information you didn't want to read: I cannot give you a set command that plops a counter in place. What I can do is tell you how to go about finding the command that will plop the counter on your page. Stay with me here and I'll get you a little closer to having a counter than you were when you began reading this page.

Why Do You Want This Counter?

     Counters look great -- granted. However, they do have several drawbacks:
  • It slows the completion of the page.
  • If the counter CGI is down, the page transfer comes to a complete stop.
  • Counters can be faulty and count incorrectly.
  • Viewers might have their in-line images turned off so will never see your count.
  • ...and honestly, how good does a counter look that only reads 15?

If I haven't talked you out of a counter, let's go on...

What Is A Counter?

     A counter is an image. In most cases, it's a bitmap. Remember that word from above? Don't let it throw you. An image is an image is an image. It shows up on your page. However, this little image comes from the CGI that you attach to. Here's the command I use to get a counter on my page:

<IMG SRC="cgi-bin/counter?width=5&link=
{} {counter.html}">

     Looks pretty scary, huh? It isn't really. The command is doing four things:

    • IMG SRC= is telling the computer that what will be returned from the CGI will be an image. Where you place the counter command on the page denotes where the image will fall.
    • "cgi-bin/counter? is the path (or URL, if you will) to the counter CGI.
    • width=5 is telling the CGI how large a counter to return
    • and{}{counter.html}" is the path back to the page that should receive the counter.

The Format Of A Counter

     This is the very basic format almost all counters follow:


     Since there are many different ways to write counter CGIs, the actual format that works for you may differ slightly from the one above, but not too much. The concept is this: it's an image -- path to the CGI -- how big do you want it -- path back to the page. I have seen some counter formats that do not have the WIDTH command and others that do not enclose the PATH TO THE PAGE in the { } brackets, but for the most part, this is the format.
I told you, this gets technical.

     Please note: The format above works for my server and my server alone. You might think (spoken with evil British accent): "Hah! The fool! He has given me the path to his counter CGI! I shall change the information in the command with my page's address so the counter will return a bitmap to me! Ha ha ha ha ha ha!" (end British accent).

No dice.

     You see, Webmasters who write these little counter CGIs know they are very popular. In turn, as is the case here, the CGI will be written so that unless you are on the same server as the CGI, you will get a nasty message back. Here's what you'll get if you attach to the CGI noted above:

Counter Only Counts Our Pages

Three Ways To A Counter

Okay, Joe. You're beginning to anger me! Can I get a counter or not?

     Sure you can. Here are three ways. All three will work, but one is just better than the others.

Find Your Own (The Best Way!)

     Always an easy answer, huh, Joe? Well, yes. It could very well be that the Webmaster of your server has a little CGI waiting just for you. All you have to do is attach to it. Contact him/her and ask. Or you can surf around to other pages on your own server and see how they got their counters to work, then follow the paths they laid out. My guess is that if you're on a server of any size or on a server that allows image maps, there's a counter CGI just waiting for a nice page like yours.

Go To A Public Domain Counter CGI (Next Best Way)

     They have those things?! Yeah, they have them. They are very over-taxed and can slow your page considerably, but they're out there.

Well, darn it! I happen to have one right here! Page Count.

     These are nice sites that allow you to choose the type of counter you want and then allows you to fill out a form that hands you the IMG format to place on your page. Read it over carefully before attaching! There are costs if your site gets more that 1000 hits a day and they make no commitment that the counter will work every time.

Attach To Someone Else's Counter (Not So Good, But It'll Work)


     I wanted to get that in first rather than have it get lost at the end of this page. Remember earlier on this page where I had you talk in the sinister British voice and say that you'd just attach to my counter by simply changing the command line from my page? Well, that's not too far from what you can do. But...


     If you see a page that has a counter on it, look at the page's source. (You can see its source by opening SOURCE under the VIEW menu at the top of the page.) Look for the IMG command that put the counter on the page. The path to the counter CGI is going to be a URL. Take just the main URL address (before all the //// directories) and log in. The main page will more than likely have blue words that allow you to write to the Webmaster.

     Write and ask for permission to make an attachment the counter.


     I DID NOT just tell you to go and attach to counters at will until you find one that works! Doing that can really tee off Webmasters who put a great deal of work into assisting their own server's patrons.

     Although you might get a counter for a short while, if you tee off the Webmaster you can be locked out just that quick. Be nice -- ask. I'll bet you get a nicer note than if the Webmaster sees you using the counter CGI without permission.

     Well, that's about all I can tell you. I know it's not a direct answer, but it will at least send you in the right direction. First, ask yourself if you really want this counter thing. If so, do the legwork! It'll pay off. You'll get a nice counter sitting right where you want it.

[Why Do You Want This Counter?] [What Is A Counter?] [The Format Of A Counter]
[Three Ways To Get A Counter] [The Best Way]
[The Next Best Way] [This Will Work, Too]


Make a Comment

Loading Comments...

  • Web Development Newsletter Signup

    Invalid email
    You have successfuly registered to our newsletter.
Thanks for your registration, follow us on our social networks to keep up-to-date