Created
October 7, 2011 17:58
-
-
Save ttrefren/1270938 to your computer and use it in GitHub Desktop.
form tracking with field values (untested)
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
$("#form_id").submit(function(e) { | |
var form = $(this).get(0), | |
submitted = false; | |
function submit_form() { | |
if (!submitted) { | |
document.createElement('form').submit.call(form); | |
submitted = true; | |
} | |
} | |
mpq.track("Form submitted", { | |
name: $(this).find(".name").val(), | |
email: $(this).find(".email").val() | |
}, submit_form); | |
// set a timeout just in case our tracking call takes too long | |
setTimeout(submit_form, 500); | |
e.returnValue = false; | |
if (e.preventDefault !== undefined) { e.preventDefault(); } | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment