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.

Effective July 1, 2023, standard Universal Analytics properties will be going away and will stop processing new hits and will be replaced with Google Analytics 4, their next-generation measurement solution.

To read more on this subject, please check out Gooogle’s support thread on this subject.

We’ve put together another tutorial on how to track successful form submissions when using Google Analytics 4. You can check out that tutorial here.

Adding the snippet

For the purpose of this documentation, we will presume you already have your Google Analytics account set up and your form created. For any assistance in creating a form, please review this article.

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, just add the snippet to your site.

For help with where and how to add snippets to your site, please review this tutorial.

 * Use Google Analytics to track submissions by form without a plugin
 * @link

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 );

In the snippet, you’ll need to provide the UA number from 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

For a more detailed explaination on the ‘ec’, ‘ea’, and ‘el’ can be found from Google Analytics Event Measurement.

The wpforms_process_complete_25 action that we’re using is because we only want to capture the analytics 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.

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


Q: Can I use this same snippet for multiple forms?

A: You can reuse this function for multiple forms but you’ll need to change the function name so that it’s unique. So instead of using ga_track_event_form_submission you’d need to change this function name each time you want to use this function on another form.

The ‘cid’ number and the action name (wpforms_process_complete_25) would also need to be updated. The ‘cid’ number should always be unique and the action name, more specifically the _25 would need to change to match each form ID used.

For assistance in how to find your form ID number, please check out this tutorial.