Track user clicks

eddie1747 used Ask the Experts™
How can I track links that a user clicks on in my webpage? I want to use javascript and then POST the clicked address to a URI.
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Hello eddie1747,

Can I ask why you do not want to use goog analytics




Yes I know that Google Analytics is a nice tool. However I am creating a project and am trying to implement some JavaScript functionality myself.
This is a seemingly simple question of endless complexity. It all depends on what and how you want to track it. Are all the links internal to your web application or do you need to track clicks on external links as well? Are you developing a web application or just building a page that is hosted by someone else (do you have access to the server-side)?

Google analytics might work for you, you should check it out. If not, you can always to "do it yourself" which would involve using AJAX on your page. If you've never heard of this, don't be afraid; it's really not that hard to do. Basically what you do is to override the onclick event on all your links to execute a function you write. In that function, you make an AJAX call to your URI, passing the link along with the call. The you redirect the browser to the request link, making at appear to the user he simply clicked the link as usual.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial