First, make sure that the DOM event is correctly fired. The event handler functions will be executed only when the event is fired.
Contact Form 7’s DOM events, such as wpcf7mailsent
or wpcf7submit
, are fired in the process of an AJAX form submission. Therefore, when your contact form is working in non-AJAX submission mode, none of the events will be fired.
Also, an event handler function won’t work when there are bugs in your JavaScript code. You can detect JavaScript errors using web developer tools built into your web browser.