Skip to content

Instantly share code, notes, and snippets.

@sampel
Created December 11, 2012 09:09
Show Gist options
  • Save sampel/4257219 to your computer and use it in GitHub Desktop.
Save sampel/4257219 to your computer and use it in GitHub Desktop.
Adding Google Analytics event tracking to outbound links
$(function() {
unction recordOutboundLink(link, category, action) {
try {
_gaq.push(['_trackEvent', category , action, 'visiting things']);
setTimeout('window.open("' + link.href + '")', 100);
} catch(err) {
console.error('Error recording outbound link.');
}
}
$('.link-box').on("click", function() {
recordOutboundLink(this, 'CF Systems', this.href);
});
});
@sampel
Copy link
Author

sampel commented Dec 11, 2012

here is the html:

<a href="http://tmview.europa.eu/tmview/welcome.html" class="link-box" target="_blank">

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment