Site statistics accumulation by means of attendance counters. Types of counters.
The article is dedicated to various counter types and their main operation principles.
The site statistics analysis is performed on the basis of the site visitors information. These data are accumulated by the web-server (then they are registered in log-files) or by attendance counters (afterwards they are stored in databases). Further operation principles of different counter types will be considered.
General principle
Counter functioning is based on the external application running during web-pages download and gaining the so called environment variables. There is all essential information about the site visitor, including:
- Visitor's IP-address (REMOTE_ADDR);
- Visitor's browser (HTTP_USER_AGENT);
- URL, where visitor came from (HTTP_REFERER);
- URL, where visitor came to (REQUEST_URI);
- Page query parameters (QUERY_STRING).
Query parameters or QUERY_STRING are indicated by ? symbol after the page address and are divided by &, for instance:
/cgi/test.php?i=34344&resolution=1024&color=32
|
The external program invocation can be performed in different ways; the most common is using a picture.
Graphic counter
As a rule, web-site pages contain a text and graphics. The text is formatted by means of specified tags; graphics presents itself a set of pictures correctly arranged.
A picture is placed in the following way:
... text of html page...
<img src=http://www.myserver.com/img/picture.gif width=468 height=60>
... text of html page...
The browser sends a request to http://www.myserver.com/img/picture.gif and the server transfers the picture file in response.
|
Note: Graphic counter functioning is based on the suggestion that while viewing your site, the user's browser downloads all the pictures - and graphic counter as well. There are two essential problems which may occur in this case:
- Some users disable picture downloading;
- Robots do not download pictures at all while scanning sites.
Thus, it will be impossible to count users with disabled pictures and to control robots activity on the site.
Statistics accumulation on the basis of a graphic counter
External application call (pretending to be a picture) is inserted instead of reference to the picture:
<img src=http://www.myserver.com/counter.php height=1 width=1>
"Counter.php" program generates the picture file and sends it to the browser. Thus, the program invocation looks like usual picture downloading for the browser.
|
The generated picture can be various. For instance, transparent GIF of the size 1õ1, or picture 88õ31 containing attendance data (total pageviews, pageviews for the current day, users for the current day), or any other.
|
While analyzing environment variables, the application gains visitor's IP-address and browser data, and registers this information in the database for further analysis. However, additional data are required for complete statistics. Query parameters string is used to transfer additional information to the application. For example, screen resolution transference may be as follows:
<img src=http://www.myserver.com/counter.php?screen=1024 height=1 width=1>
The additional user data is gained by means of java-script: a referrer, screen resolution, colour depth, random number, enabled cookie etc. That is why you have to insert large amounts of counter codes in java-script while using a graphic counter.
It is possible to collect information about most users with the help of graphic counter; however, search bots and users with disabled pictures will not be considered.
Counter as a program inclusion
Nowadays most sites are dynamic: their pages are generated on the fly by visitor's request. These pages are written with the help of a program language, mainly PHP, ASP, JSP. I.e. web-site pages are in fact applications and possess their own environment variables. For instance, we can write a PHP-code, which will be accumulating visitor's data and storing it in the database, but it won't be displaying any visual information. For convenient insertion into web pages, it is usually packaged as one file and then installed.
For instance, CNStats program inclusion counter code (PHP-Include) looks as follows:
... php-code ...
include "/usr/www/users/www.myserver.com/cnstats/cnt.php";
... php-code ...
|
As counter code is included into the page code, all the visitors will be counted assuredly without any notice. However, there are certain disadvantages in using a program inclusion:
- The visitor's data can be taken only from environment variables;
- It is rather complicated to define the visitor's uniqueness.
Combined counter: a program inclusion plus picture
The essence is as follows: the program inclusion code is inserted into dynamic web-pages; it will be displaying graphic counter code. As a result:
- The program inclusion code is invoked at the moment of the page generation; the information gained from environment variables is stored in the database;
- Java-script code of the graphic counter appears on the generated page;
- While the browser downloads the page, java-script displays the graphic counter with the additionally accumulated information;
- The additional user data collected by java-script is registered in the database.
The statistics accumulation system becomes more complicated (besides, combined counter type does not always fit), but at the same time, it is the only variant of accumulating the maximum complete information about all the visitors. Combined counters are progressive.
Conclusion
You have gotten acquainted with basic counter types. We hope that this information will be useful and will help you to choose the most convenient way of the site statistics accumulation.
Finally, we would like to give some advises:
- You should use universal software products, which support different counter types: they will give you the opportunity of a choice;
- You should use combined counter - it is a brand-new achievement in the statistics accumulation sphere.
|