Skip to content

Instantly share code, notes, and snippets.

@RafeHatfield
Created May 18, 2013 05:41
Show Gist options
  • Save RafeHatfield/5603371 to your computer and use it in GitHub Desktop.
Save RafeHatfield/5603371 to your computer and use it in GitHub Desktop.
quick jquery script to track clicks on the site
$(function(){
$('a').click(function(){
var source = '';
var destination = '';
var link_text = '';
source = window.location.pathname;
if($(this).attr('href')){
destination = $(this).attr('href');
}else if($(this).attr('onclick')){
destination = $(this).attr('onclick');
}else if($(this).attr('area')){
destination = $(this).attr('area');
}
link_text = $(this).text();
$.post("http://www.suite101.com/click_tracker.cfm", { source:source, destination:destination, link_text:link_text });
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment