• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 401
  • Last Modified:

FP counter visibility

I run several web sites each with a FP hit counter. Idealy I would like each site to deposit the counter reading into a table from which a graph of hits vs day would be drawn. However this looks like a two month programming job. I will settle for

some ideas on how to make the counter readabel only by me.

E-mail me once a day, print hits in the background color, print hits on an unlisted page, or ?
  • 4
1 Solution

Here is a hit counter that i based on ASP and can write to the database,  you can view the counter or not.  How to install it? it is very easy.

1- Create a new page in Frontpage
2- Switch to HTML view
3- Delete all the HTML code that you see
4- Copy the following code into the HTML area which is blank now.  Copy the code as it is to Notepad then from notepad to the new blank html page that you have created in Frontpage.  Copy the code between the ---------------- lines.  

------------------------------------ The CODE Below This --------------------------------------

'*     ASP 101 Sample Code - http://www.asp101.com/    *
'*                                                     *
'*   This code is made available as a service to our   *
'*      visitors and is provided strictly for the      *
'*               purpose of illustration.              *
'*                                                     *
'*      http://www.asp101.com/samples/license.asp      *
'*                                                     *
'* Please direct all inquiries to webmaster@asp101.com *

<strong><%= RetrieveAndIncrementCount() %></strong>
' I placed this in a function so I wouldn't have to worry about
' any namespace collisions.  For example... if this was inline
' code and someone named a variable strSQL in a file this file
' gets included into you'd get an error.  This way you don't and
' there's no chance of the variables overwriting one another!
Function RetrieveAndIncrementCount()
      ' From adovbs.inc:
      Const adOpenKeyset = 1
      Const adLockPessimistic = 2
      Const adCmdText = &H0001

      ' Local variables
      Dim strFilename
      Dim strSQL
      Dim rsCounter
      Dim iCount

      'Get filename and build SQL query
      strFilename = Request.ServerVariables("SCRIPT_NAME")
      strSQL = "SELECT page_name, hit_count FROM hit_count WHERE page_name='" & strFilename & "';"

      'Open our recordset
      Set rsCounter = Server.CreateObject("ADODB.Recordset")
      'Access version:
      rsCounter.Open strSQL, _
      "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("counter_db.mdb") & ";", _
      adOpenKeyset, adLockPessimistic, adCmdText
      ' SQL Server version:
      'rsCounter.Open strSQL, "Provider=SQLOLEDB;Data Source=;" _
      '      & "Initial Catalog=samples;User Id=samples;Password=password;" _
      '      & "Connect Timeout=15;Network Library=dbmssocn;", _
      '      adOpenKeyset, adLockPessimistic, adCmdText

      ' If we've got a record then we read the current value
      ' If we don't then we create one, set the filename, and start at 0
      If rsCounter.EOF Then

            iCount = 0

            rsCounter.Fields("page_name").Value = strFilename

            iCount = rsCounter.Fields("hit_count").Value
      End If

      ' Increment the count and update the DB
      rsCounter.Fields("hit_count").Value = iCount + 1

      ' Close our connection
      Set rsCounter = Nothing

      ' Return the count (pre-incrementation).
      RetrieveAndIncrementCount = iCount
End Function

--------------------------------- END of CODE ----------------------------------------

5- Save the page as

6- Create a database in Access to have the following:
Database name: counter_db.mdb
Database table name: hit_count
Database table fields: page_name (text), hit_count(numeric)

7- Import the database into your webfolder

8- Make sure that the database has permission for Everyone and Internet Guest Account to write to the database.  Grant write permissions for Everyone and Internet guest account.

9- Open the page that you want to place the hit counter on

10- Copy the following line to the body of the page
<!--#include file="counter_db_inc.asp"-->
You can put this line in the body of each and every page you want to count  because the counter can count the hits for each page and in the page_name field,  the code will write the name of the page and the total hits.

I modified the code to be used for Access database.

Just create the database as I told you
Save it
Give it permissions
Stick to the field names and page names I gave you

Withing 10 minutes you will have your own counter.

If you don't want to display the counter for users you can change this line which is at the top of the long code:

<strong><%= RetrieveAndIncrementCount() %></strong>

<strong><font color="#FFFFFF"><%= RetrieveAndIncrementCount() %></font></strong>

This will make the font color white on a white page.  Change the color according to the background color of your page.

This is a very nice counter,  it counts the hits of every page when it is visited.

Please do not hesitate to ask.


You can use the database to create any chart you want.

Also,  I gave you two essential fields in the database that get populated by the code,  you can add other fileds like time and date which will have a default value.  So,  you can tell whenever the page is visited.

You better try this counter,  it is easy to install and it will work fine.  I tried it myself.  It is very informative and you can use it for later statistics.

aburrAuthor Commented:
answer looks good. I am half way down the page the bottom of which I will place the counter
Good luck
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now