Skip to content

Instantly share code, notes, and snippets.

@johnnyopao
Last active December 15, 2022 11:39
Show Gist options
  • Save johnnyopao/a1efd7c29a8a0ec95de2 to your computer and use it in GitHub Desktop.
Save johnnyopao/a1efd7c29a8a0ec95de2 to your computer and use it in GitHub Desktop.
Triggering GA events for image/text links on Unbounce
<script>
// Replace #lp-pom-image-13 with the ID of your image or text box. Be sure to retain the trailing 'a'
$( '#lp-pom-image-13 a' ).click( function(event) {
event.preventDefault();
var buttonLink = $(this).attr("href");
if (typeof ga != 'function') {
window.location = buttonLink;
}
//Edit the event components below as needed
ga('send', 'event', 'button', 'click', 'label', {
'hitCallback' : function () {
window.location = buttonLink;
}
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment