Created
May 13, 2015 23:55
-
-
Save johnnyopao/3ccb2707b59ea1aedeff to your computer and use it in GitHub Desktop.
Atrribute conversion on form submission to previous Unbounce page
This file contains hidden or 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 type="text/javascript"> | |
function yourSubmitFunction(e, $) { | |
e.preventDefault(); | |
var _ubaq = _ubaq || []; | |
_ubaq.push(['trackGoal', 'convert']); | |
var ub_script = document.createElement('script'); | |
ub_script.type = 'text/javascript'; | |
ub_script.src = | |
('https:' == document.location.protocol ? 'https://' : 'http://') + | |
'd3pkntwtp2ukl5.cloudfront.net/uba.js'; | |
var s = document.getElementsByTagName('script')[0]; | |
s.parentNode.insertBefore(ub_script, s); | |
$('.lp-pom-form form').submit(); | |
} | |
lp.jQuery(function($) { | |
$('.lp-pom-form .lp-pom-button').unbind('click').bind('click.formSubmit', function(e) { | |
if ($('.lp-pom-form form').valid()) yourSubmitFunction(e, $); | |
}); | |
$('form').unbind('keypress').bind('keypress.formSubmit', function(e) { | |
if (e.which === 13 && e.target.nodeName.toLowerCase() !== 'textarea' && $('.lp-pom-form form').valid()) | |
yourSubmitFunction(e, $); | |
}); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment