GA Link Tracker for WordPress

I’ve had a few instances in the past where client installs of WordPress should have had internal and outbound links tracked by Google Analytics via some type of link tracker, but either:

  1. The site admin was a designer and didn’t give a shit about metrics, or
  2. The site admin didn’t know how to add tracking code to important links.

So, I created a tiny WP plugin to track events of link clicks in the main content area of the site. Install it and forget about it. Links will show up under Events in the Analytics site, and will have a category of Links, a label of PageID: CURRENT_PAGE_URI, and the value of the href of the link being tracked. Yes, there are more robust solutions – yes, there are other plugins that track more data points. This one suits my needs perfectly with no messing about with bloat. A simple link tracker with a fire-and-forget install.

Links will look like this:
onclick="javascript:_gaq.push(['_trackEvent', 'Links', 'PageID: /my_blog/2013/04/my_post/ ', 'http://www.myurl.com/my_blog/my_link.html']);"

The above example assumes the href of the link is: http://www.myurl.com/my_blog/my_link.html

Install instructions:

  1. Upload GA-Link-Tracker.php to the /wp-content/plugins/ directory
  2. Activate the plugin through the ‘Plugins’ menu in WordPress
  3. All done!

Plugin page on WordPress: wordpress.org/extend/plugins/ga-link-tracker/
Plugin .zip: GA-Link-Tracker.zip

One thought on “GA Link Tracker for WordPress”

Leave a Reply to alsoreadingthexmen.tumblr.com Cancel reply

Your email address will not be published. Required fields are marked *