Question

Hope this question is Genuine !!

I have a form with jquery validation, every field is validated on keypress and submit.

Is there a way I can send every validation error to google analytics.

I am able to send if I use javascript custom validation, but not sure about jquery validation plugin.

Code sample:

$(document).ready(function(){
//validate form
$('#sign-up').validate({
    rules: {
        / .... /
    },
    messages: {
        / .... /
    }
    highlight: function(element) {
        /..../
    },
    success: function(element) {
        /..../
    },  

    /* Some code which sends all error messages to google analytics event */
    /* On keyup and on submit error messages */
    /* GA code sample - _gaq.push(['_trackEvent','Sign up', 'Sign up validation', 'Dynamic error message' )]); */       

    submitHandler: function() {
        $.ajax({
            /..../
        }); // ajax
    } // submitHandler
  }); // validate (jQuery Plugin)   
}); //doc ready
Was it helpful?

Solution

Quote OP:

"I am able to send if I use javascript custom validation, but not sure about jquery validation plugin."

If you can already do this in a custom JavaScript function, then you should be able to put that inside the invalidHandler callback function. It's fired whenever the submit button is clicked on an invalid form.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top