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:
- The site admin was a designer and didn’t give a shit about metrics, or
- 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:
- Upload
GA-Link-Tracker.php
to the/wp-content/plugins/
directory - Activate the plugin through the ‘Plugins’ menu in WordPress
- All done!
Plugin page on WordPress: wordpress.org/extend/plugins/ga-link-tracker/
Plugin .zip: GA-Link-Tracker.zip
Great info thanks for this