We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 30912
    • 463 Posts
    Hello all,

    Im wanting to track the form submissions via google analytics, I know its possible with a thank you page, but I dont ideally want to take the visitor away from the page they are viewing.

    I came across this https://contactform7.com/tracking-form-submissions-with-google-analytics/
    for Contact7; which mentions the event listener for the form and was wondering if Formit has the same facility and I can tag/track the event when a submit happens

    The Contact7 post above there is this code for the listener.

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


    Does Formit have an equivalent 'wpcf7mailsent' event?

    Thanks in advance.

      • 17301
      • 932 Posts
      You could always use the FormItSaveForm hook if you wanted to record the form submissions and keep track of the count per form.
        ■ email: [email protected] | ■ website: https://alienbuild.uk

        The greatest compliment you can give back to us, is to spend a few seconds leaving a rating at our trustpilot: https://uk.trustpilot.com/review/alienbuild.uk about the service we provided. We always drop mention of services offered by businesses we've worked with in the past to those of interest.
        • 30912
        • 463 Posts
        Thanks, but I already save the form data, I just want to track it so our Marketing Dept can measure their click throughs and whatever else they are doing with the data.
          • 5160
          • 118 Posts
          You can create a goal in Analytics and register a form submission with a JavaScript call.

          You can initiate the JavaScript call sheet manually on successful form validation or with a Form of hook.

          No code examples to hand as using phone but felt if you want to see this on a contact form from one of my sites.
          • Looks like you almost have all the pieces already. Instead of listening to wpcf7mailsent, listen to submit and add the event listener to the form, instead of document. That should do the trick to log it in to Google analytics events.
              Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

              Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
              • 30912
              • 463 Posts
              Sorry been working on a totally separate project and forgot to follow up.

              Thanks Mark I will look into that.