Skip to content

Instantly share code, notes, and snippets.

@gloriousgeneralist
Last active December 26, 2015 22:29
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
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