Here is a short tutorial about how to track Any Link Click with Google Analytics.

The first thing you will have to do is add a short snippet of code to the link you want to track. The code snippet you are adding is actually an OnClick JavaScript event handler that will be executed when the link is clicked and make Google Analytics take note of it. What you have to add is this the following:

onClick="javascript: pageTracker._trackPageview(‘/Links/Test’);"

You can change "/Links/Test" to whatever you want, I will explain later what is it good for.

your tracked href should look like this:

<a href=http://www.dev102.com/ onClick="javascript: pageTracker._trackPageview(‘/Links/Home’);"> Test Link</a>

Now we are ready to check out Google Analytics and for the results.

Log into your Google Analytics account do the following:

  1. Click on "Content" in the Menu (in red)

    Google Analytics Menu

  2. Look at the bottom of the page for the Top Content Section and click "view full report" (in red)

    Content Overview Google Analytics

  3. Look at the bottom of the screen there will be a textbox where you can type.

    Filter Content Google Analytics

    Now it is time to remember what we wrote in the OnClick event of the link, I wrote (‘/Links/Test’) so if I type "Test" in this textbox and click go I will get all the Content that was viewed by readers With Test in the URL, and it will include all the clicks on that Link that we added the OnClick event handler. So there you go, you now know how many clicks were maid on you link.

Need help? Have a better way to track links? Please comment

Enjoy

Amit.

Tags :

13 Responses to “How To Track Link Clicks With Google Analytics”


  1. Topil James

    Said on August 29, 2009 :

    Hi!
    I don’t understand one thing,
    where do you insert the code Test Link

    Thanks for your help

  2. marcosz

    Said on December 14, 2009 :

    this doesn’t work reliably since you can’t predict whether the href or the onclick wil be executed first.

    the href may take you to another page before the onclick executes.

  3. Susan Reed

    Said on April 16, 2010 :

    I have a question.
    Where do you insert the code and what is the code? Am I to assume that this is on Google? or do I need to insert some code in my head tag?

    Please clarify. Thanks,
    Susan Reed

  4. Jamie

    Said on May 2, 2010 :

    Isn’t the link address supposed to be in quotation marks? so do I quote the whole thing or break it up?

  5. GoosPoos :: Web & Software Technology Blog

    Said on July 9, 2010 :

    Can this track dynamic links like social bookmark buttons, where links are generated using dynamic php code like php_title etc.

  6. Mike

    Said on September 15, 2010 :

    I tried this for 3 links on my site for about 35 mins. I copied the code and placed it in the href tag but it showed up in the text, so I added a space after the actual link, and then the link itself added the onClick, which broke the link. Seemed like good instructions, but not as simple as Amit makes it sound. Looking elsewhere for more adequate instructions.

  7. kenny

    Said on November 5, 2010 :

    Is it possible to use this approach to track links going away from my site to a different site?

    Thanks!

  8. Alan

    Said on March 16, 2011 :

    This is too much trouble, just use a shortener service that has tracking, for example, use unily.it

  9. Freelance Gigs Marketplace

    Said on July 13, 2011 :

    It’s probably good for the small sites, but how can you manually code links in large dynamic sites?

  10. kiran

    Said on August 17, 2011 :

  11. akmal

    Said on October 15, 2011 :

    man it isn’t showing up in analytics/content/view full report. there is a, i guess, a landing page report. can’t see the link tracking?

  12. Backlink Service

    Said on March 16, 2014 :

    For newest information you have to pay a visit web and on the web I found this web site as a finest web page
    for most up-to-date updates.

1 Trackback(s)

  1. Dec 4, 2010: How to track links with Google Analytics | tutorials blogs

Post a Comment