Skip to content

Instantly share code, notes, and snippets.

@kengos
Last active December 11, 2015 09:18
Show Gist options
  • Save kengos/4578638 to your computer and use it in GitHub Desktop.
Save kengos/4578638 to your computer and use it in GitHub Desktop.
<script type="text/javascript">
//<![CDATA[
$(function(){
$("body a[href^='http://']").on("click", function(){
url = $(this).attr('href');
if(url.indexOf($(location).attr('hostname')) == -1)
{
_gaq.push(['_trackEvent', 'Link', $(location).attr('href'), url]);
}
});
});
//]]>
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment