How to Track Successful Form Submissions Without a Plugin


Would you like to track your successful form submissions without the need for another plugin? Using one of the many WPForms hooks and a little PHP code snippet you can easily track the form submissions inside Google. In this tutorial, we’ll give you the snippet needed and walk you through setting up these tracking events.


For the purpose of this documentation, we will presume you already have your Google Analytics account set up and running. If you need any assistance with setting up your Google Analytics, please review this tutorial.

Once you’ve set up your Google Analytics and your form, you’ll just need to copy this code snippet to your site.

function ga_track_event_form_submission( $fields, $entry, $form_data, $entry_id ) {
  $endpoint = '';
  $payload_data = array(
    'v' => 1,
    'tid' => 'UA-XXXXXXXXX-1',
    'cid' => 123,
    't' => 'event',
    'ec' => 'Forms',
    'ea' => 'Successful Submission',
    'el' => 'Contact Us'
    $parameters = http_build_query( $payload_data );
    wp_remote_post( $endpoint . $parameters );
add_action( 'wpforms_process_complete_25', 'ga_track_event_form_submission', 10, 4 );

There are a few things you’ll need to update in the code snippet above. And they are:

  1. 'tid' => 'UA-XXXXXXXXX-1', – this is a unique number assigned to you when you created your Google Analytics account. To find this number just go to the Admin section in your Google Analytics Dashboard and click on the Users tab.Copy your UA number from Google
  2. wpforms_process_complete_25 – this is the hook that we’re using but only for the form ID 25. You’ll need to update this to match your own form ID. For help locating your form ID, please review this tutorial.
  3. If you are going to use this code snippet on more than one form, as you update the form ID number as mentioned above, you may also want to make sure that the 'cid' number is unique to each form.

Once that code snippet is added, you’ll start seeing your data being recorded in your dashboard.

You can now track successful form submissions without the need of another plugin

And that’s it! You’re now able to track successful form submissions without the need for another plugin. Would you like to be able to limit the years that displays in your Date form field? Take a look at our article on How to Limit the Years Inside Your Date Picker.

Action Reference: wpforms_process_complete