Skip to content

Instantly share code, notes, and snippets.

@GaryUnbounce
Created February 18, 2014 22:04
Show Gist options
  • Select an option

  • Save GaryUnbounce/9081290 to your computer and use it in GitHub Desktop.

Select an option

Save GaryUnbounce/9081290 to your computer and use it in GitHub Desktop.
Tracking Click-Through Button Clicks with Universal Analytics
<script>
$( '#lp-pom-button-23' ).click( function(event) {
event.preventDefault();
var buttonLink = $(this).attr("href");
if (typeof ga != 'function') {
window.location = buttonLink;
}
ga('send', 'event', 'button', 'click', 'unbounce', {
'hitCallback' : function () {
window.location = buttonLink;
}
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment