A jQuery plugin to automatically add Google Analytics tracking to certain links.

  • Finish writing the unit tests.
  • Register on Bower.io

The code below...

<script src="/path/to/jquery.js"></script>
<script>
var _gaq=[['_setAccount','Your Tracking Code Here'],['_trackPageview']];
(function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];
g.src=('https:'==location.protocol?'//ssl':'//www')+'.google-analytics.com/ga.js';
s.parentNode.insertBefore(g,s)}(document,'script'));
</script>
<script src="dist/jquery.cw-event-tracking.min.js"></script>
<script>
jQuery(function($) {
	$('a').CWEventTracking();
});
</script>
			

... allows all links on pages with the script to be passed as goals to analytics.

Property Type Default Description
v0.2.0 19th March 2015 Added support for Universal analytics (with thanks to Jon Catmull).
v0.1.2 18th March 2015 Updated bower config again to remove lib folder.
v0.1.1 18th March 2015 Updated bower config.
v0.1.0 2nd March 2014 Created the first version of the script based on previous created scripts.