Compile a website traffic statistics system using ASP

Source: Internet
Author: User
Most of the current website statistics systems are CGI, but the compilation is particularly complicated. ASP is simple to learn and has the advantages of combining with databases, so I will discuss with you how to compile a website statistics system based on my previous website statistics system.
Everyone has seen NetEase's website statistics system, which can count the total traffic, average daily traffic, daily traffic, maximum traffic, maximum access date, daily traffic analysis, and monthly traffic analysis, weekly traffic analysis, browser analysis, and so on.
In fact, the key to making an ASP access statistics system is the design of the system table structure. And how to collect user CGI variables and display user information. That is to say, the key to the system is two ASP Programs, statistical programs and display programs.
First, let's take a look at how to collect user access information.
When writing access statistics, we need to know the following information about the user. The visitor's IP address (the visitor's IP address list can be formed based on the access IP address ), visitor's browser and operating system (view the ratio of visitor's browser to the operating system and all visitor's browsers to the operating system), visitor's access time (perform daily access Volume Analysis, monthly access Volume Analysis, weekly traffic analysis). Let's take a look at the statements that use ASP to obtain the above information:
1. Obtain the visitor's IP address
Dim M_IP
M_IP = Request. Servervariables ("REMOTE_HOST ")
The preceding statement can be used to obtain the visitor's IP address.
2. Obtain browser information
Dim O_Browser, M_BrowserType
Set O_Browser = Server. Createobject ("MSWC. BrowserType ")
M_BrowserType = O_Browser.Browser + O_Browser.Version
3. Obtain the access time
Dim M_DateTime
M_DateTime = Year (Date () & "/" & Right ("0" & Month (Date (), 2) & "/" Right ("0" & Day (Date (), 2) & "/" & Right ("0" & Hour (Time (), 2) & ":" & Right ("0" & Minute (Time (), 2) & ":" & Right ("0" & Second (Time (), 2)
4. Obtain the user's operating system.
Use the following statement in ASP to obtain the visitor's http_user_agent string.
Dim StrUserAgent
StrUserAgent = Request. ServerVariables ("HTTP_USER_AGENT ")
This string is generally in the following format:
Mozilla/4.0 (compatible; MSIE 4.01; Windows 98)
The above string indicates that the visitor uses Windows 98 and the browser uses MSIE 4.01. However, the string format is not fixed and can be changed by yourself.
The other main UserAgent strings we see are as follows:
Use the IE browser:
Mozilla/2.0 (compatible; MSIE 3.01; Windows 95)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.