Capture form using input changed trigger instead of clicked or submit

gerard_reyes Posted by: Gerard Reyes Date Posted: July 15, 2024
Back to Case Studies

Issue

The lead is not being captured because the capture event is not firing on the form submission. Even the usual click of the submit button does not fire the capture event.

Solution

I added a code to fire the capture event on changing an input value.

 

document.addEventListener('change', function(event) {
     var target = event.target;
     if (target.matches('.ctct-form-custom input[name="email_address"]')) {
         mcfx('capture', target.closest('form'));
         console.log('MCFX capture success');
     }
});

Achievement

The lead was captured.

Snippet/Screenshot/Link

Ticket: Link