Tracking outgoing links, downloads and RSS feed subscriptions with Google Analytics

by Dipali on December 21, 2008 · 2 comments

in Google Analytics

Google Analytics can be applied to any links so that they are recorded when clicked on. This is done by tagging the link itself; though Google are looking to make it a default setting in a future update. Tagging a link assigns a defined page view to any click on the link.

For example, to track every click on a particular link to www.google.com as a page view for “/offsite/google.com” you would add the following code to the link’s code:

<a href=”http://www.google.com” onClick=”javascript: pageTracker._trackPageview (’/offsite/google.com’);”>

It is a good idea to group all your offsite links into a logical directory structure to easily identify the pages visitors clicked on to leave your site.

Google Analytics can be applied to assign a page name to any downloads or button clicks (such as an RSS feed button) in the same manner.

For example, to log every click on a particular link to  as a page view for “/uploads/dwarakadhish_jagat_mandir_dwarika” you would add the following attribute to the link’s code:

<a href=”http://www.vaishnavparivar.info/Pushtimarg-Articles/wp-content/uploads/dwarakadhish_jagat_mandir_dwarika.jpg onClick=”javascript: pageTracker._trackPageview (’/downloads/dwarakadhish_jagat_mandir_dwarika.jpg’);”>

Or to log every click on an RSS feed button as a page view for “/buttons/RSSFeed” you would add the following attribute to the link’s code:

<a href=”http://feedproxy.google.com/NarendraModi” onClick=”javascript:pageTracker._trackPageview(’/buttons/RSSFeed‘);”>

To track each of these links as conversion goals, the created page view names can just be added to the goal configuration page.

In order for link tracking to work, the Google Analytics tracking code needs to be placed before the onClick code so that the javascript function _trackPageview is defined first. This can be done by placing the Google Analytics tracking code in the header instead of the footer; just place it after the opening <body> tag.

More info:

http://www.google.com/support/googleanalytics/bin/answer.py?hl=en&answer=55529

http://www.google.com/support/googleanalytics/bin/answer.py?hl=en&answer=55527

Previous post:

Next post: