Setup Google Tag manager for Contact Form 7. Focus fields when an error occurs.
jQuery(document).ready(function($) {
$(".wpcf7").on('wpcf7:mailsent', function() {
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
'event': 'formSubmitSuccess',
'formId': 'contactForm'
});
}).on('wpcf7:invalid', function() {
// focus errors on contact form
window.location.hash = $('.wpcf7-not-valid').get(0).id;
});
});