1 of 1 people found this helpful
But I'm not sure how I would even implement this. However, I currently have this block of JS code that executes when the form is submitted:
Technically, that code executes after the form has been submitted, not when (onSuccess is critically different from onSubmit).
In your specific case, you can add the line
ga('send', 'event', 'Contact Form', 'submit');
directly above the line
in your onSuccess function.
However, this only works because you are staying on the same page after form submit. If you were instead redirecting the user to another page, you could not do the GA logging this simply, and otherwise comparable code that attempts to do so is broken.