'Google Tag Manager Form Submission with Formik

Try as I may, I am unable to successfully track any form submissions with Google Tag Manager when the form is submitted by Formik in a React project. I have tried every possible variable, trigger, tag option that I can find. Nothing. gtm.formsubmit is never firing.

Any ideas why?



Solution 1:[1]

Event has to be prevent before send to formik. My current workaround:

const handleSubmit = event => {
  formFormik.handleSubmit(event.preventDefault());
};

<form id="form-test" onSubmit={handleSubmit}>
 ...
</form>

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Hubert Makowski