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

6 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 🙂


Leave a Reply

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