Track user clicks

Posted on 2008-11-06
Medium Priority
Last Modified: 2012-05-05
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.
Question by:eddie1747
LVL 16

Expert Comment

ID: 22893990
Hello eddie1747,

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



Author Comment

ID: 22894018
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.

Accepted Solution

pellep earned 500 total points
ID: 22894059
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.

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question