File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes How to track a link click Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » JSP
Reply Bookmark "How to track a link click" Watch "How to track a link click" New topic
Author

How to track a link click

Brian Ata
Greenhorn

Joined: May 22, 2010
Posts: 27
Hi all,

I have a question regarding the issue of tracking user clicks on hyperlinks. What I am trying to establish is in "Product Review" page, if a user clicks on "Report Abuse" link located under a review, I want to show a thank you note and stop that user ever clicking on that specific link again.

What I am thinking is detecting the mouse click on tag with JQUERY and capturing the unique reviewID from href attribute of that link, and submit it to a servlet via AJAX. This sounds reasonable. But after that in order to stop that user clicking to that specific link again, I have to associate that web user id (logged in users can only see reviews) with that specific review, which means I need to insert that user id to persistent store and associate it with that review for tracking.

And as for the view, this time I need to filter reviews by using logged in user's id to enable that "Report Abuse" link or not, which seems relatively computationally expensive when compared to just showing the reviews.

So I am wondering, when I think about the problem, this is the first solution that came to my mind without serious tinkering.

How you guys do it? Is there a way, pattern to follow to solve such a problem.

Thank you for reading, your time.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 13842

I wouldn't do anything on the client. When the user clicks on a link, that generates a request which is sent to the server. So I would just make a servlet filter, or something like that, which notices such requests and updates your "link-clicked" database accordingly.
Brian Ata
Greenhorn

Joined: May 22, 2010
Posts: 27
I am inclined in the same way, thinking about doing it server side.

I am just wondering how good it sounds in terms of engineering. I ask myself this question, "is preventing same user to report a problem with the same review more than one time critical?" , the answer is no, so it opens the door for client side approach, but even it is not critical, for the looks, I need to disable that link-at least during the session, and that can be done.

I was checking facebook and realized that the "Poke Back" functionality is client side. First time you poke back, that function disables itself until you do a browser refresh, which in turn means they are even not caring it to disable during user session either-looks like a simple ajax call and respond.

But again this will be the first time I face this problem, so I am interested in optimum solution.

Thank you.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 13842

I guess it depends on how much you're using client-side processing. The method I outlined would refresh the page, presumably with the "post review" button disabled. But if refreshing a page is an uncommon occurrence in your application and it would look strange to your users, then looking for an Ajax solution would be a good idea.
Brian Ata
Greenhorn

Joined: May 22, 2010
Posts: 27
Thank you Paul,

I will begin the task, and will sail with the wind. If I encounter something unique and interesting along the way, I will post here to share.

 
 
subject: How to track a link click
 
Threads others viewed
How to disable BACK button of the browser?
Acegi Login Problem
Problem with commandLink
j_security_logout issue
Session Overriding
developer file tools

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture