Track user clicks

Posted on 2008-11-06
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

    Hello eddie1747,

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



    Author Comment

    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.
    LVL 4

    Accepted Solution

    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.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    Suggested Solutions

    In this tutorial I will show you how to provide a dynamic RTF document on your website generated with data from your database. For this tutorial you will need Microsoft Word or WordPad, WhizBase and Microsoft Access. In this tutorial I will show …
    Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
    The viewer will learn how to count occurrences of each item in an array.
    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…

    794 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

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now