Probably the most common form of event tracking or goal objective for a website is to track when a user has successfully submitted a contact form, the best way to do this is to ensure that the website is configured to redirect the browser to a Thank You page.
One of the most common plugins used in WordPress is the Contact Form 7 plugin. There are two options with Contact Form 7 you can download and install Contact Form 7 Redirection Plugin
If you don't want to add another plugin to your WordPress setup the hard code option is very simple. We do recommend that you work with a child theme version of your main site theme.
The code should be added to your footer.php file and goes before the closing </body> tag. Update the link to the URL of your thank you page.
<script>
document.addEventListener(
'wpcf7mailsent'
,
function
( event ) {
},
false
);
</script>