Track user clicks

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.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Hello eddie1747,

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


eddie1747Author Commented:
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.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.