how a counter works?

Can you tell me how a counter works (as simple as you can):
1. Is a counter just some script code in the page HTML program?
2. Or, we must use some program in the server?
3. Is the free counter only a link to the site that can analyze my web?
learnAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
shiversConnect With a Mentor Commented:
a hit counter requires a value to be stored on the web server - this value is incremented with each request to the page concerned.

There are two main ways of achieving this - all involve a call to a CGI program residing on the server.

1 - <IMG> tag: graphical counters increment the value and then dynamically stitch together a GIF image which is returned to the browser.

2 - SSI include: the #exec command in a Server Side Include line can instruct the server to execute a counter CGI which will return a text string showing the number of hits

some of the more advanced CGIs can handle multiple pages with their own counts - a parameter in the CGI call specifies the particular page you are counting.  

the way that most free coutners work is with an IMG tag to a CGI on their server - with a parameter identifying your page.  Their counter will then return a dynamically created image that shows the number of hits to your page and your page only.

If you're interested in looking at some CGIs, go to www.cgi-java.com and look at the cgi/counters section


0
 
learnAuthor Commented:
Hi shivers,

Thank you.

Say, I got a web site based on server1 and a counter based on server2. Do you mean server2 checks my web every minutes to see how many visitors visiting my web and I can go to a page of server2 to get the data?

Can I just put some script code in my page without the help from other server?
0
 
shiversCommented:
for the first part:

no - no checking is done by server2 - but when a user acccesses the page on server1, the browser looks at the HTML code and sees where all the images are located and downloads them all - the counter one will be located on server2, so the browser contacts server2 to obtain that image - this invokes the CGI which increments the counter number and returns an image reflecting the value of that number

for the second part:

only if you use server side scripting that can store information in a database or file on the server (such as PHP).  Javascript/VBscript is client side (executed in the browser) and so cannot be used for a counter
0
 
shiversCommented:
oops, also:

i dont know if any free counter servers offer extra stats on who has visited your site - the usual way to check the number of hits is just to visit your own page and look at the counter number; of course this will also have the effect of incrementing the counter as well
0
 
learnAuthor Commented:
To shivers:

Thank you very much.
0
All Courses

From novice to tech pro — start learning today.