• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to track a link click

 
Brian Ata
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 21872
36
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 21872
36
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!