Skip to content

Instantly share code, notes, and snippets.

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

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

Select an option

Save GaryUnbounce/9081342 to your computer and use it in GitHub Desktop.
Tracking Button Click with Google Analytics (classic)
<script>
$( '#lp-pom-button-23' ).click( function(event) {
event.preventDefault();
var buttonLink = $(this).attr("href");
var callbackFunction = function(){
window.location = buttonLink;
}
if(window._gat){
_gaq.push(['_set','hitCallback',callbackFunction]);
_gaq.push(['_trackEvent', 'button', 'click', 'buttonTest']);
} else {
callbackFunction();
}
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment