Skip to content

Instantly share code, notes, and snippets.

@dannevang
Last active April 14, 2021 07:30
Show Gist options
  • Save dannevang/5621118 to your computer and use it in GitHub Desktop.
Save dannevang/5621118 to your computer and use it in GitHub Desktop.
Track mailto events in Google Analytics with jQuery. Normal ga.js and jQuery is required.
$(document).ready(function() {
$('a[href^="mailto"]').click(function(){
_gaq.push(['_trackEvent', 'email', 'send', this.href.replace(/^mailto:/i,'') + ' /Page = ' + location.href,,true]);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment