page-hit & download counter : home
Examples of how to use Unicounter
|
- This web page uses the filename extension .shtml.
This normally enables server-side includes, however, your server may have other requirements.
- All tables have visible borders to make them clearer, cell-spacing
= 0, cell-padding = 2 and automatic sizing for both tables and cells.
- Instead of using single-cell tables to achieve a colored background, style sheets may be used.
- You may need to view the source code of this page to fully understand how it all works.
- Parameters must be separated using the & character.
When called using <script>
or <a> tags, etc. & must be encoded
as &
Encoding is required simply to keep the HTML code valid
- the browser will translate & into &.
When called using server-side includes or javascript functions, etc. no such encoding is required or permitted.
- Normally you should enable IP tracking by setting trackip to a non-zero value.
Zero is used in some examples below to better demonstrate the counter action.
The default value for trackip is 8. It is used only when a counter is created, thereafter, the value is read from the counter file.
In the examples below, the blue text is present in the source
code at the point where the counter value is displayed
<script
type="text/javascript"
src="/cgi-bin/counters/unicounter.pl?name=test1&cache=1&trackip=0">
</script>
- This counter will normally increment each time the page is
refreshed, but may not increment when the page url is reentered.
This is due to caching. For instance, if you use the forward
and backward buttons on your web browser, this counter is likely
to remain unchanged.
<script
type="text/javascript"
src="/cgi-bin/counters/unicounter.pl?name=test2&cache=0&trackip=0">
</script>
- Note the use of the parameter cache=0.
- If not specified, cache=0 is assumed.
- This counter should increment whenever the page is refreshed, the page url is reentered,
or the forward/backward buttons of your browser are used, etc.
<script
type="text/javascript"
src="/cgi-bin/counters/unicounter.pl?name=test3&trackip=4">
</script>
- This counter tracks ip addresses
- This counter should remain constant when the page is refreshed.
If you have access to another computer with its own internet
connection (and therefore it own IP address) then opening this
page from the second computer will cause the counter on that
computer's page to be one greater than on this computer's page.
However, if you click the refresh button on this computer, both
will become synchronised.
- This computer will not cause the counter to be incremented
until four other computers have accessed this page.
<!--#include virtual="/cgi-bin/counters/unicounter.pl?name=test4&write=ssi&trackip=0" -->
- This example requires server-side includes to be enabled on the server.
- The url is similar to example 3 but requires the additional parameter write=ssi.
It should behave identically to example 3.
Download counters come in two parts being the delivery
and the display.
You must set the target of the download link to an url that
calls the counter and specifies the file to be downloaded.
The current value of the counter is displayed below. If after
downloading, you refresh the display, the counter should have
incremented.
Click
here to test the download counter.
/cgi-bin/counters/unicounter.pl?name=test5&trackip=0&deliver=http://www.skaro.net/unicounter/unicount.zip
- The url specified by the deliver parameter must be
complete. A relative url is likely to fail though this may depend
on your server.
- The write parameter, if present, will be ignored if deliver is specified.
This is very much the same as for page-hit counters, however,
the parameter inc=0 is required to prevent the value of
the counter being incremented.
<!--#include virtual="/cgi-bin/counters/unicounter.pl?name=test5&write=ssi&inc=0&trackip=0" -->
- This example requires server-side includes to be enabled on the server.
When called using a server-side include, the parameter write=ssi is required.
- The url is similar to example 4 but has the additional parameter inc=0.
- Normally, you would place the display next to the link.
- To display the link and the download count on the same line,
you may wish to create a table with one row and two columns.
It's a matter of personal preference when designing the page
layout. Of course, if you don't want coloured backgrounds you
need not use tables at all.
Pictorial page-hit counters
|
Provided that you don't wish to display the counter value on a page, you may avoid both server-side
includes and javascript. In this case, you must use an <img>
tag.
<img src="/cgi-bin/counters/unicounter.pl?name=main_ph&deliver=http://www.yourdomain.com/images/counter.gif" alt="counter">