Last active
December 15, 2022 11:39
-
-
Save johnnyopao/a1efd7c29a8a0ec95de2 to your computer and use it in GitHub Desktop.
Triggering GA events for image/text links on Unbounce
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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