Created
May 18, 2013 05:41
-
-
Save RafeHatfield/5603371 to your computer and use it in GitHub Desktop.
quick jquery script to track clicks on the site
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(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