Visit or Contact Us | Jobs
A-Z Index
 Home   Library   About Lincoln   Academics   Admissions   Financial Aid   Students   Alumni   Athletics   Continuing Education   Research & Extension   Faculty & Staff   

Students
Conduct
Enrollment Management and Student Success
Media
» OIT Help Desk
· Service Request
Computer Labs
» Hints & Tips
Datatel
· Internet Access
Order a Computer
· Telephone
» Website
» Create a Counter
· Landing Page Format
· Site Builder Manual
· Spell Checker Installation
· Uploading Files
Contact Us
Residential Life
Student Accounts
Student Affairs
Student Assessment
Student Life
Student Support Services
Thompkins Health Center

 

Home » Students » OIT Help Desk » Hints & Tips » Website » Create a Counter Sitemap

Office of Information Technology

Create a hit counter

Creating a hit counter is as easy as 1-2-3!

Step 1

You will need to know the page number of the page where the counter is to be displayed.  For example, to put a counter on THIS page, your page number would be 1485.asp.

Step 2

Paste the following CODE into your document where you want the page counter to appear.  Remember, you must paste it in CODE VIEW, not editing view.

The Code-- paste everything between the two lines
--------------------------------------------------------------

<P align=center><EM>You are visitor number <%
Dim fsoObject
Dim tsObject
Dim filObject
Dim lngVisitorNumber
Dim intWriteDigitLoopCount
Set fsoObject = Server.CreateObject("Scripting.FileSystemObject")
Set filObject = fsoObject.GetFile(Server.MapPath("hitcounters/count000.txt"))
Set tsObject = filObject.OpenAsTextStream
lngVisitorNumber = CLng(tsObject.ReadAll)
lngVisitorNumber = lngVisitorNumber + 1
Set tsObject = fsoObject.CreateTextFile(Server.MapPath("hitcounters/count000.txt"))
tsObject.Write CStr(lngVisitorNumber)
Set fsoObject = Nothing
Set tsObject = Nothing
Set filObject = Nothing
Response.Write(lngVisitorNumber)
%>&nbsp;since Month 00, 2000</EM></P>

--------------------------------------------------------------

Step 3

Edit the code to reflect YOUR counter file name.  You will  need to make THREE changes.

Change the MapPath to your counter number-- this will be the same as your page number.  For example:

change:  (Server.MapPath("hitcounters/count000.txt"))
To:        (Server.MapPath("hitcounters/count1485.txt")) [for this page]
    -- Do this in TWO places --

Next, change the 'since' date to the current month, day and year

 since Month 00, 2000  becomes   since December 06, 2006

------------------ Finished Result --------------------------------

You are visitor number 1831 since December 06, 2006

 

All content © Lincoln University http://www.lincolnu.edu
2009 All rights reserved.