Outbound Google Analytics tracking on a WordPress RSS widget

Today I ran into the fact that outbound links from the standard WordPress RSS widget are not tracked by Google Analytics for WordPress. Unfortunately I have been unable to find a WordPress plugin for an RSS widget that does track the outbound links. However before embarking on a journey to create a widget with this feature myself, and finally add something to the community that gave me so much, I tried out the KB advanced RSS widget.

Fortunately this widet gives you control over the output it generates. This made it fairly easy to add the GA tracking code to the widget by replacing the code in the last text area of the widget with:

<li><a class=’kbrsswidget’ href=’^link$’¬†onClick=”javascript:pageTracker._trackPageview(‘/outbound/rss/^link$’);” title=’^description$’¬†>^title$</a></li>

Hope this will be of use to someone.

Comments