Contact Form 7 is a popular contact form plugin for WordPress and has callbacks available out of the box.
Simple change the ‘xxx’ value to the forms ID that you want to fire an event for. In the example below, standard Google Analytics Event has been used but can be replaced with GTAG or GTM Events. The if statement can also be used multiple times to target multiple form ID’s
<script type="text/javascript"> document.addEventListener( 'wpcf7mailsent', function( event ) { if ( 'xxx' == event.detail.contactFormId ) { ga('send','event','contact-form','submit'); } }, false ); </script>