This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Servlets and the fly likes tracking links in a db Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "tracking links in a db" Watch "tracking links in a db" New topic

tracking links in a db

Anthony Smith
Ranch Hand

Joined: Sep 10, 2001
Posts: 285
I have a website with multiple pages. I want to track when a user clicks on any link from my site. The thing that came to mid initially was a onClick property that when onClick, the javascript function would be called to write to the db. This wont work. What are my other options.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15951

If you mean that you have links to other sites and you want to track when someone "clicks out", the common approach is to embed the actual destination in a server request. Like this:
< a href="" >Bye now!< / a >
Then the tracklink.jsp can capture and log the destination and redirect the request.
Fair warning, though - I'm notorious for using the "open in a new window feature" myself, so I may not have completely left your site!

Customer surveys are for companies who didn't pay proper attention to begin with.
It is sorta covered in the JavaRanch Style Guide.
subject: tracking links in a db
Similar Threads
onClick() doesn't work for Image, any work around!!
Use Value of Another Tag in Onclick Event
saving multiple rows
The DHTML Calendar-custom onclick
Adding onClick Event to the Button Using Java Script