Skip to content

Instantly share code, notes, and snippets.

@ttrefren
Created October 7, 2011 17:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ttrefren/1270938 to your computer and use it in GitHub Desktop.
Save ttrefren/1270938 to your computer and use it in GitHub Desktop.
form tracking with field values (untested)
$("#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