Support » Plugin: Contact Form 7 Google Analytics » Doesn’t seem to load the event code

  • Resolved nickth


    The event listener code with wpcf7mailsent doesn’t seem to be showing up in View Code. Uninstalling to try another method.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author macbookandrew



    It partly depends on the version of Contact Form 7 you have installed. If you’re using a version prior to or including 4.7, it will add the Javascript inline in the document. Otherwise, it will load a separate script file: /wp-content/plugins/cf7-google-analytics/js/cf7-google-analytics.min.js.

    If you don’t see that either, keep in mind that caching plugins (WP Rocket, WP Fastest Cache, etc.) often merge and minify scripts to improve performance.

    Ty. Though this plugin is causing TWO events to show, and on top of the CF7 code I had in the site, THREE events are being reported per submission. Here’s your duplicate code:

    1. document.addEventListener(“wpcf7mailsent“,function(e){cf7GASendTrackingEvent(e.detail.contactFormId,”Mail Sent“)},!1)

    2. document.addEventListener(“wpcf7submit“,function(e){cf7GASendTrackingEvent(e.detail.contactFormId,”Sent“)},!1);

    CF7 says to use:
    3. document.addEventListener( ‘wpcf7mailsent‘, function( event ) { ga(‘send’, ‘event’, ‘Contact Form’, ‘submit‘);}, false );


    Why do you use duplicate code, one for sent and submit, that results in two similar events?
    Why differ from CF7’s instructions?

    I think I should disable this plugin for now until you reply and we get this sorted out.

    Plugin Author macbookandrew



    The duplicate events is expected behavior because the “Sent” event was initially the only event CF7 provided, and I kept it around in case people had old goals depending on it.

    The third example you provided is an old example from before CF7 provided the different actions as well.

    I just released v1.8.0 of this plugin with options to disable any of the events individually.

    Ty, good solution.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Doesn’t seem to load the event code’ is closed to new replies.