Quantcast
Channel: Dev102.com » JavaScript
Viewing all articles
Browse latest Browse all 7

How To Track Link Clicks With Google Analytics

$
0
0

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.


Copyright © 2008
This feed is for personal, non-commercial use only.
The use of this feed on other websites breaches copyright. If this content is not in your news reader, it makes the page you are viewing an infringement of the copyright. (Digital Fingerprint:
)

Viewing all articles
Browse latest Browse all 7

Trending Articles