Skip to content

Instantly share code, notes, and snippets.

@gloriousgeneralist
Last active December 26, 2015 22:29
Show Gist options
  • Save gloriousgeneralist/7223014 to your computer and use it in GitHub Desktop.
Save gloriousgeneralist/7223014 to your computer and use it in GitHub Desktop.
Using jQuery for creating database outgoing links custom events. You obviously need to replace the 'a.db_name' with whatever class you wrap your database links in. If you are using this in Drupal, as I am, use instructions here to make your life easier when creating jQuery objects: https://drupal.org/node/171213#comment-4686396.
<!--Database custom events-->
<script type="text/javascript">
$(document).ready(function(){
$('a.db_name').each(function(){
var db_name = $(this).text();
$(this).click(function(){
_gaq.push(["_trackEvent", "linkOut", "database", db_name]); // create a custom event
});
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment