Click Through Counting   
 

Here's a click-thru counter you can use to count how many times a link and/or graphic has been clicked. What you need are three things:

Here's the code:

We'll be assuming that you're making a click-thru counter for www.psacake.com. ;)


Open up a text editor such as WordPad or whatever you use to code, and paste the below code and save it as psacake_counter.asp

<%
Set FileObject = Server.CreateObject("Scripting.FileSystemObject")
HitsFile = Server.MapPath ("/counter") & "\psacake_hits.txt"
Set InStream= FileObject.OpenTextFile (HitsFile, 1, false )
Oldpsacake_hits = Trim(InStream.ReadLine)
Newpsacake_hits = Oldpsacake_hits + 1
Set OutStream= FileObject.CreateTextFile (HitsFile, True)
OutStream.WriteLine(Newpsacake_hits)
%>



Now create a text file called psacake_hits.txt and type "0" in the file as the initial hit. The Server.MapPath is the directory under your root where this text file is saved. For example, I have a folder called counter directly under the root directory where my psacake_hits.txt is stored (/counter) The codes above read the number in the text file, add it with 1, overwrite the old hit, and display it.
psacake_hits.txt must have write rights given to it either for everyone or at the very least IUSER_MachineName

Now create the redirect file. Paste the following code and name it psacake_redirect.asp

<% Response.Buffer = True %>
<!--#include file="psacake_counter.asp"-->
<% Response.Redirect "http://www.psacake.com" %>


Now use the below html tag for the link or graphic you want to show a click-thru count for:

Instead of having <a href="http://www.psacake.com">
use
<a href="www.yourURL.com/psacake_redirect.asp">Click Here</a>


My3C's
perrychicker
It's easy... it's a PSACAKE!
Back | Tell A Friend | Search this Site
© 1998 - 2008 psacake.com
Version 3.23

Send me One Million FREE Guaranteed Visitors