Conversion Tracking using Contact Form 7 and Custom JS

Hi,

I have a couple of Contact Form 7 forms on my site and would like to track conversions using Google Analytics.
Currently, event CF7 event tracking is implemented as a short JS snippet that needs to be implemented in the page header.

See here: https://contactform7.com/tracking-form-submissions-with-google-analytics/

Question: Is it also possible to include the JS snippet into the custom JS section of page builder?
Or do I need to include it into the header over a child theme?

Thanks and cheers
Sebastian

Hello Sebastian,

Thanks for posting in!

Is it also possible to include the JS snippet into the custom JS section of page builder?

  • Yes you can.

The GA code should be added in the header. It would be easier if you use Google Analytics plugin so that the code snippet for the GA is easier for you to manage.

As for the event tracking with Contact form, you can insert it in the JS section of the page builder. You will just have to remove the script tags. So for example, the JS code should only be this:

document.addEventListener( 'wpcf7mailsent', function( event ) {
    ga('send', 'event', 'Contact Form', 'submit');
}, false );

Hope this helps. Kindly let us know.