Articles in this section

Track Form Submission With JavaScript

Although Hotjar tries to properly track when a form has been submitted successfully or not, this doesn't always work. This is due to the way forms are validated and what happens following a successful or failed validation - in a few cases, Hotjar isn't able to automatically guess whether a submission has been successful or not.

For this reason, using JavaScript you can tell Hotjar when a particular form was successfully submitted or not, depending on whether it passed your validation criteria or not. Using this technique has the added benefit of making the data collected much more accurate since you will be able to use your own validation function to tell Hotjar what to track.

Events

When a form is successfully submitted, the following code should be used:

hj('formSubmitSuccessful');

When a form fails validation, the following code should be used:

hj('formSubmitFailed');

Usage Example

Let's assume that this is the function that handles your form's submissions: