information technology central services at the university of michigan MondayMay262003

counter

home / how-to / cgi-scripts / counter

Counter - an approximate count of hits on your page

Counter allows you to display an image representing an access counter on a given page. To put a counter on a page, include a tag like:

<img src="http://cgi.www.umich.edu/counter?link=
http://www.umich.edu/~umweb/index.html">

Note: This line must appear in your html document on only one line. If you copy and paste any of the counter examples from this page to your own document, be sure to edit the file and remove any line breaks in the counter link.

Counter options

The link= argument specifies the URL to be counted. It is required. Additional arguments must be separated from each other by ampersands (&)

The ignore= argument specifies IP addresses (141.211.164.2) or domain names (terminator.cc.umich.edu) that are forbidden from incrementing the counter.

The font= argument specifies a font to use instead of the counter's default. If you have a freely available truetype font that you would like to see added to this list please submit download information, author's name, and contact information to webmaster. We will not be able to add every font that is submitted.

The width= argument specifies how many digits are displayed & has a maximum of ten. If you specify a width that is too small for the number being displayed, the counter will use only as many digits as it needs. If you specify too large a width, the counter will pad the number being displayed with zeros.

The rand= argument will cause the counter to display a different random number everytime your page loads.

The reset= argument allows you to reset the counter to a specific value. NOTE: after resetting your counter to the desired value, remove the 'reset=' from your IMG tag to begin counting from the new value.

The text= argument allows you to set the font color using the "web color" scheme. For instance, to get a counter with black text, set "text=000000". Note that "#" is interpreted as an anchor by the browser, and as such must be ommitted. "text=#000000" will not behave as you expect.

The bgcolor= argument allows you to set the background color using the "web color" scheme. For instance, to get a counter with a white background, set "bgcolor=ffffff". Note that "#" is interpreted as an anchor by the browser, and as such must be ommitted. "bgcolor=#ffffff" will not behave as you expect.

The point= argument allows you to set the point size of the counter. Note this will only work in conjunction with the font= argument, as the default font cannot be sized.

The image= argument allows you to make the counter generate PNG images rather than the default image format, JPEG. JPEG has been chosen as the default image format because, being rendered internally by most browsers, JPEG images appear to load more quickly and match the other colors presented by the browser better than PNG files. However, the image quality of JPEGs is lower than that of PNG. PNG appears to be slower on some browsers ( those that use a helper application to render the images may appear to "hang" for a moment when loading the counter image ) but the quality is superb.

Counter options

There is only one required argument in the counter: link=URL. There are other, optional arguments, each of which needs to be separated by & signs. All of the applicable arguments are listed below:

Example default Example Image Description
link=http://www.umich.edu none The URL of the page using the counter.
rand=true rand=false Whether or not to display a random number.
font=gd gd is the default font The digit style of the counter.
font=transit
font=stylus
font=steamer
font=buff
font=zoinkfat
font=simpson
font=adlibn
font=signboard
font=arial
font=comic
font=courier
font=impact
font=trebuchet
font=verdana
font=lumos
width=9 width=0 This setting determines how many digits are displayed & has a maximum of ten.
reset=1202 none Used to reset the counter to a specific, non-negative value.
text=9933ff text=ffffff Used to set the font color of the counter.
bgcolor=ffffff bgcolor=000000 Used to set the background color of the counter.
point=36 point=20 Used to set the point size of the counter font.
image=png image=jpeg Used to set the output format of the counter image.