Tracking WPForms Submissions with Google Analytics

WPForms is a great form builder plugin for WordPress which offers a host of benefits including integration with a number of 3rd parties such as Mailchimp, PayPal, Stripe, Zapier Integration and much more.

However, like many form builder plugins for WordPress, the ajax based WPForms lacks integration with Google Analytics. While the Plus and Pro versions of WPForms may offer further functionality, the Lite and Basic seemingly fail to offer Google Analytics integration as standard. There’s no way to redirect customers to a dedicated ‘Thank You’ page nor is there any way to trigger custom code (i.e. a Google Analytics Event) upon successful form completion, therefore making it very difficult to track the volume of form completions within Google Analytics.

jQuery Event tracking Solutions for WPForms

Luckily, when a customer has successfully submitted information via WPForms they are presented with a confirmation message such as this:

WPForms Confirmation

This confirmation message utilities a DIV with a unique ID relating to the ID of the form:

WPForms Confirmation Code

So we can use a quick jQuery script with the on document ready function to check for the existence of this ID and trigger an event within Google Analytics:

This code should be inserted into your footer.php file ahead of the closing tag.

Please note that the ‘XXXX’ above will relate the to unique ID of your form, therefore you’ll need to find your ID and modify the code above to suit.

WPForms Overview

Also note that the above code is configured to work with the new Global Site Tag for Google Analytics, but can easily be adapted to work with the legacy versions such as Universal Analytics (analytics.js), for example:

That’s it. A quick, easy and effective jQuery solution for tracking Google Analytics events with WPForms.

A few people have asked how to configure the goal within Google Analytics. I’m going to assume that you have already registerd with Google Analytic and deployed the required tracking code throughout your website. If you haven’t made it that far, I suggest you read Google’s Get started with Analytics guide before you go much further.

As for configuring the goal, assuming you have not altered the code provided above, you can simply configure the goal as follows:

WPForms Goal Configuration

16 thoughts on “Tracking WPForms Submissions with Google Analytics

  • “This code should be inserted into your footer.php file ahead of the closing tag.”,I have done this,but i did not know how Google analytics works?
    can you explain more on this?
    Also how can see the conversion on google adwords?

    • Short answer, yes it would. Hopefully you’re utilising child themes to manage the customisation of your theme – if not, you should be 🙂

  • Hi there, I’ve done this, but I have no idea how to set up a goal with these parameters? I want to set up a goal in order to see how many people fill out the wpforms contact form. I have on my site. I also have no idea how I would know if your instructions are working. I’ve put this code within the footer.php below the but above the

    Thanks so much

    • Hi Alee,

      Setting up the goal in Google Analytics is quite straight forward, assuming you have implemented the script correctly.

      1. Log into Google Analytics
      2. Navigate to the correct Google Analytics ‘Property’ and select the correct data ‘View’
      3. Click the ‘Admin’ link (left hand column at the bottom)
      4. Beneath the ‘View’ column (the right hand column), click ‘Goals’
      5. Click the ‘+ New Goal’ button
      6. Under ‘Goal set-up’ select ‘Custom’
      7. Give the goal a name (such as ‘Contact Form Completions’)
      8. Under ‘Type’ select ‘Event’ and click ‘Continue’
      9. Set ‘Category’ for ‘Form Completion’, and set ‘Action’ to ‘Submitted’ (based on the code provided in this post; assuming you haven’t changed these variables)
      10. If you have multiple forms and you require a goal to differentiate between each form, you can specify the ‘Label’ field (in my example the label is set to ‘Demo Enquiry Form’)
      11. Click ‘Save’
      12. Mission accomplished!

      That should be all you need to start tracking the volume of form submissions from WPForms in Google Analytics.

      Let me know how you get on 🙂


  • This flat out refuses to do anything, using either the gtag or ga code. No event data received in analytics except the standard form entry and exit fields. But no events sent on confirmation, and yes I definitely have the right form ID and I’ve put the code in the correct place.
    I’ve inspected the page source code and everything is appearing correctly exactly as you indicate but still no event sent to analytics the div id is in my source code and it matches exactly (apart from the # you said to add at the start) the javascript. This seems like really simple code but it flat our isn’t doing anything, and now I have wasted an hour on this already and I want to throw this machine through a window? How can this be trouble shot? I can’t seem to inspect anything through tag manager. Should I try loading this code with tag manager?

  • OK, well for people who are using Tag Manager, you can achieve the same thing by using “Element Visibility” as a trigger, and you need to input “wpforms-confirmation-XXXX” as your element ID, then obviously add the tag to send an event to Analytics. Hope this may be of some use to someone.

  • This worked perfectly for me. Thank you Chris. I used the Head, Footer and Post Injections plugin to insert the code into the section of every page (not the footer). I then set up an Event goal in Analytics that matched Category, Action and Label from the code Chris provided. After doing this you can test it is working by submitting a form and going to Analytics / Real-Time / Events. The last step is to import the Analytics goal into Google Ads to track conversions.

  • Currently using the free forms tab in WP. Not a specific plugin. How best can I track the form submissions without getting a new plugin that I’d have to download?

  • Worked for me, cheers! Used Adam Ford’s tip for setting the trigger up in GTM (his second comment where he’d resisted throwing his machine out the window). All good!

  • Here’s an alternative that worked for me:

    jQuery( document ).ready( function() {
    jQuery( document )
    .on(‘click’, ‘#wpforms-submit-xxxxx’, function() {
    ga(‘send’, ‘event’,’Form Completion’,’Submitted’,’Demo Enquiry Form’);

      • The problem with this approach James is that a click on the submit button is not indicative of successful submission. What happens if a required field is omitted so the form fails to validate? Your jQuery will trigger an event even though the form was not successfully processed. That’s why I avoid button clicks if I can.

Leave a Reply

Your email address will not be published. Required fields are marked *