How to track WordPress form submissions
Tracking form submissions lets you measure key conversions, gauge campaign effectiveness, and see how visitors interact with your site. This guide shows how to fire a custom event to Usermaven after a successful submission in the most-used WordPress form plugins and offers a fallback thank-you page method.
Before you begin
- Make sure the Usermaven tracking script is installed and active.
- Enable AJAX submission in your form settings whenever possible—required for the JavaScript hooks below.
- If your form does reload the page, use the thank-you-page method or track a page-view event instead of the custom hooks.
Two ways to track a form
Method | When to use |
---|---|
Custom event tracking (recommended) | Form submits with AJAX; you want instant, reliable events without extra pages. |
Thank-you page redirect | Works with any plugin or non-AJAX form; requires no code, just a redirect. |
The steps below focus on the custom-event method. A thank-you-page section follows.
Tracking code for popular form plugins
Copy the snippet for your plugin and add it to WordPress (see How to add code below).
Contact Form 7
document.addEventListener('wpcf7mailsent', function (event) {
if (typeof usermaven === 'function') {
usermaven('track', 'Form Submitted', {
form_plugin: 'Contact Form 7',
form_id: event.detail.contactFormId
});
}
});
WPForms
document.addEventListener('wpformsAjaxSubmitSuccess', function (event) {
// event.detail contains the payload when listening on document
const data = event.detail;
if (typeof usermaven === 'function') {
usermaven('track', 'Form Submitted', {
form_plugin: 'WPForms',
form_id: data.formId,
form_name: data.formName
});
}
});
Note: If you attach the listener with jQuery
$('form').on('wpformsAjaxSubmitSuccess', (_, data) => { … })
, the payload arrives as the second argument (data
).
Gravity Forms
// Requires jQuery (bundled with WordPress)
jQuery(function ($) {
$(document).on('gform_confirmation_loaded', function (e, formId) {
if (typeof usermaven === 'function') {
usermaven('track', 'Form Submitted', {
form_plugin: 'Gravity Forms',
form_id: formId
});
}
});
});
Ninja Forms
// Requires jQuery
jQuery(function ($) {
$(document).on('nfFormSubmitResponse', function (e, response) {
if (typeof usermaven === 'function') {
usermaven('track', 'Form Submitted', {
form_plugin: 'Ninja Forms',
form_id: response.id // payload comes as 2nd arg
});
}
});
});
Formidable Forms
// Requires jQuery
jQuery(function ($) {
$(document).on('frmFormComplete', function (e, form, response) {
if (typeof usermaven === 'function') {
usermaven('track', 'Form Submitted', {
form_plugin: 'Formidable Forms',
form_id: form.id
});
}
});
});
Fluent Forms
// Requires jQuery
jQuery(function ($) {
$(document).on('fluentform_submission_success', function (e, form, response) {
if (typeof usermaven === 'function') {
usermaven('track', 'Form Submitted', {
form_plugin: 'Fluent Forms',
form_id: response.form_id || form.attr('data-form_id')
});
}
});
});
Enriching your events with more data
You can attach extra context such as dropdown selections, campaign IDs, or the current page title.
Privacy reminder
Never include personally identifiable information (PII) like name, email, or phone in event properties. Usermaven links events to a user profile automatically, keeping you compliant with GDPR and CCPA.
Example (Formidable Forms) – adding a non-PII field and page title:
jQuery(function ($) {
$(document).on('frmFormComplete', function (e, form, response) {
if (typeof usermaven === 'function') {
const inquiryType = response.posted_data.inquiry_type || 'Not specified';
usermaven('track', 'Form Submitted', {
form_plugin: 'Formidable Forms',
form_id: form.id,
inquiry_type: inquiryType,
page_title: document.title,
page_path: window.location.pathname
});
}
});
});
How to add the code to WordPress
A) 3rd party plugin - WPCode – Insert Headers and Footers (easiest)
- In the WordPress admin, go to Plugins → Add New.
- Install WPCode – Insert Headers and Footers + Custom Code Snippets.
- Navigate to Code Snippets → Add Snippet → Add Your Custom Code.
- Title it, set Code Type to JavaScript Snippet, and paste your code.
- Choose Site Wide Header, save, and activate.
B) functions.php
(developer route)
add_action( 'wp_footer', function () { ?>
<script type="text/javascript">
/* paste the JavaScript snippet for your plugin here */
</script>
<?php } );
Use a child theme or custom plugin so updates don’t overwrite your changes.
Alternative method: thank-you page redirect
- Create a new page, e.g.,
/thank-you
. - In your form settings, set the confirmation action to Redirect to URL and enter that page.
- In Usermaven, use ‘Page visit’ option when creating a conversion goal, funnel or reports with
/thank-you
as the parameter.
How to verify tracking
- Visit a page with the form.
- Submit a test entry; the Form Submitted event should appear in Usermaven.
- In Usermaven, open Configure > Custom events page to watch incoming events.
- (Optional) In your browser’s DevTools → Network tab, filter for
events.usermaven.com
to see the POST request and payload.