By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,952 Members | 1,722 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,952 IT Pros & Developers. It's quick & easy.

How to Record hits to website

P: 63
I set up an Access database with a text field to record the website name and a date field to record the date/time of the access. I have set up a page with various anchors set up to call up different websites. When the user clicks a particular anchor, I want to be able to record this information to the database. Is there an event which can be connected to the anchor and update the database?
Jun 10 '08 #1
Share this Question
Share on Google+
2 Replies

Expert 100+
P: 432
That depends.

Is the web page built in .asp or (.aspx)?

You would need to use an onclick event but the problem is that unless the site is built in the onclick event can only be captured in javascript on a regular HTML or .asp page.

The other option is if it is classic asp (.asp) you can instead have the link point to one of your own pages (say Process.asp) that is a redirect handler, and write out the counts before directing them.

So if you set up a series of links and assign them an code each of your links would start to look like this:


Then on the process page just do this

Expand|Select|Wrap|Line Numbers
  2. 'Process.asp
  3. dim MyLinkCode
  4. MyLinkCode = request.querystring("linkid")
  6. Select Case MyLinkCode 
  7.      Case "01"
  8.           '
  9.           sql = "insert into MyTable (name,date) VALUES ('',Date)"
  10.           dbconn.execute sql
  11.           'then you actually send them to the page
  12.          response.redirect("")
  13.      Case "02"
  14.           '
  15.           sql = "insert into MyTable (name,date) VALUES ('',Date)"
  16.           dbconn.execute sql
  17.           'then you actually send them to the page
  18.          response.redirect("") 
  19. End Select
If you are in fact using for your pages you could do this a different way by using the link controls, and use the onclick event to capture the users click, rather then redirecting them.
Jun 11 '08 #2

P: 63
I passed to an intermediate page, saved to the database, and then re-directed to the correct page. Thanks for the help.
Jun 24 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.