visitor (0 QPoints)
  • FR
  • EN
  • NL
  • DE
  • ES
315 experts, 1193 registered users, 1659 questions already answered
European Experts Exchange, the very best site for high-quality IT solutions

New Improved Search!

 


05/10/2011 1h30 : Steve Jobs is dead, the father of Apple ][ is gone, we are all orphaned.

Web :: General :: track client browser's clicks on A links, log them to server...


By: Nono Great Britain  Date: 24/03/2007 09:53:21  English  Points: 20 Status: Answered
Quality : Excellent
Ok I log everything on my site from every click to every page view, but one thing I can not log is clicks for anchors. Like so /index/blah/#contents I cant log the #contents bit because it occurs on the client side. Is there any way to do this other than using JS to make an onclick() handler to grab the url and submit silently in background via AJAX.

I just want to see which areas of content are being viewed the most so can reposition etc.

thanks!
By: VGR Date: 24/03/2007 09:56:02 English  Type : Answer
Creating an OnClick() global event handler for each link to send it in background with xmlhttp is clearly overkill.

You've an alternative, equally overkill :
You can log it by using a standard redirect server script.

so don't use a href="{$PHP_SELF}#something" (the {} element is implicit) but use a href="go.php?destination={urlencoded(}{$_SERVER['PHP_SELF']}#something{)} (the {} element has to be urlencoded)

Perhaps the best idea is to "simply" via JS manipulate the src attribute of an hidden img ; this would in turn trigger a server request to a server/PHP script returning the correct image type and fake data, but mainly logging the action. This should work fine.

Do register to be able to answer

EContact
browser fav
page generated in 89.732890 milliseconds

Why Google AdSense ads ?

compteur
 Ranking-Hits PageRank for this page