Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter nturne

    (@nturne)

    Hello danielgc. I believe it works OK, but it hasn’t been subjected to rigorous testing yet – the only website that I needed to install it on is a very small (and low traffic) website, but I haven’t had an issue so far. If you try it yourself and later have any feedback, maybe you could post it?

    Thread Starter nturne

    (@nturne)

    I think I’ve answered my own question…

    I have added the following to my child theme functions.php file and it appears to work:

    function hook_google_analytics() {
    	echo "<script>\r\n";
    	echo "document.addEventListener('wpcf7mailsent', function(event) {\r\n";
    	echo "	if ( '5' == event.detail.contactFormId ) {\r\n";
    	echo "		ga('send', 'event', 'Contact Form', 'Submit');\r\n";
    	echo "	} else if ( '179' == event.detail.contactFormId ) {\r\n";
    	echo "		ga('send', 'event', 'Quote Reservation', 'Submit');\r\n";
    	echo "	}\r\n";
    	echo "}, false );\r\n";
    	echo "</script>\r\n";
    }
    add_action('wp_head', 'hook_google_analytics');

    In this case the standard contact form has an ID of ‘5’ and the quote form has an ID of ‘179’ (taken from the shortcode).

    Any comments would be appreciated.

Viewing 2 replies - 1 through 2 (of 2 total)