NCS Logo - Click for home page Northstar Developer Center
Platforms
All Platforms
.NET Framework (1.x - 4.x)
Active Server Pages
ASP.NET
C#
SQL Server
VB.NET
Visual Basic

Keywords
.NET Data Types
.NET E-mail
.NET Events
.NET Functions
.NET Object Programming
.NET System.Configuration
.NET System.Diagnostics
.NET System.IO
.NET System.Net
.NET System.Net.Sockets
Active Data Objects
ASP Architecture
ASP Black Belt
ASP Built-in Functions
ASP Built-in Objects
ASP Debugging
ASP Performance
ASP Security
ASP Syntax
ASP.NET Authentication
ASP.NET Controls
ASP.NET Data Access
ASP.NET Features
ASP.NET Master Pages
ASP.NET Page Events
ASP.NET Security
ASP.NET ViewState
Atom
Certifications
COM, DCOM, COM+
Data Access
E-Mail
Errors
Exporting Data
HTML Tips
IIS
Object-Oriented Programming
RSS
SQL
Uncategorized ASP Tips
VB API Programming
VB Forms
VB Syntax
XML

Book Support
Visual Basic 6 Bible
ASP Bible
ASP Weekend Crash Course
ASP.NET At Work
Creating Web Services

Creating a Page Counter

Written by Eric Smith, Northstar Computer Systems LLC

A number of readers have asked about creating page counters, so I thought I’d dump a few ideas as to how to create counters. Older style counters relied on a graphic being loaded on each page being counted, and this is still possible. Simply create an IMG tag like this:
<img src=”mycounter.asp” height=1 width=1>
The mycounter.asp page is responsible for counting the page hit and redirects the output to an invisible, 1x1 pixel graphic, for instance.

A more elegant and efficient way is to call a function in the page to record a hit to a permanent storage system, like a database. The database can record the page name (from Request(“SCRIPT_NAME”)) and increment the number of pages through a quick stored procedure. A timestamp can be added on automatically, if necessary, or you can simply update the total if you’re not tracking the actual hits.

In short, there are lots of ways to count your visitors…it just depends on what you’re going to do with the information eventually.

Keywords: [ Uncategorized ASP Tips ]

Publication Date: 3/1/2000