WPForms conversion tracking in Google Tag Manager works best when you listen for the plugin's wpformsAjaxSubmitSuccess jQuery event, push a dataLayer event with the form ID, and fire your GA4 and Google Ads tags from a Custom Event trigger. That event only fires after the server accepts the entry, so failed validation, CAPTCHA failures and blocked spam do not count. It requires AJAX submission to be on for the form.
This is for agency owners, PPC managers and developers who run tracking on WordPress client sites that use WPForms. It covers the JavaScript events WPForms fires, how each confirmation type changes what you can track, a GTM listener you can paste, GA4 and Google Ads setup, enhanced conversions, the MonsterInsights overlap that causes double counting, how spam settings affect your numbers, and multi-page forms. Everything here was checked against the WPForms Lite 2.0.x source code.
How do you track WPForms conversions with Google Tag Manager?
You track WPForms conversions in GTM by catching the success event WPForms fires after an AJAX submission and turning it into a dataLayer event your tags can use. The short version:
- Turn on AJAX. In the form builder, go to Settings, then General, open the Advanced section and switch on Enable AJAX form submission. Save the form.
- Add the listener. Create a Custom HTML tag in GTM with the listener code below, firing on DOM Ready for the pages that hold forms.
- Create the trigger. Add a Custom Event trigger for the event name
wpforms_submit_success. Add a condition on the form ID if you only want some forms to count.
- Create the variables. Add Data Layer Variables for
wpforms_form_id, wpforms_confirmation and wpforms_entry_id.
- Attach your tags. Fire a GA4 Event tag and a Google Ads Conversion Tracking tag on that trigger.
- Test it. Submit the form in GTM Preview mode, confirm one event per submission, then check GA4 DebugView and the Google Ads conversion diagnostics.
Our Google Tag Manager form tracking guide explains why listeners beat click and submit triggers in general. Below is the WPForms specific detail.
Which JavaScript events does WPForms fire on submit?
WPForms fires a set of jQuery custom events on the form element during an AJAX submission, and wpformsAjaxSubmitSuccess is the one to use for conversions. These names come from the plugin's front-end script, wpforms.min.js, in the current release.
| Event | Fired on | When it fires | Use for tracking? |
wpformsAjaxBeforeSubmit | Form | Right before the AJAX request is sent | No. The entry has not been accepted yet. |
wpformsAjaxSubmitSuccess | Form | Server returned success, before the confirmation is shown or the redirect starts | Yes. This is your conversion signal. |
wpformsAjaxSubmitBeforeRedirect | Form | Success with a page or redirect confirmation, just before the browser leaves | Only as a hint that navigation is about to happen. |
wpformsAjaxSubmitSuccessConfirmation | Form container | After the confirmation message HTML replaces the form | Possible, but it only fires for message confirmations. |
wpformsAjaxSubmitFailed | Form | Server returned errors, for example validation, CAPTCHA or anti-spam errors | Useful for an error event, never for a conversion. |
wpformsAjaxSubmitError | Form | The request itself failed, for example a server error or timeout | Error reporting only. |
wpformsAjaxSubmitActionRequired | Form | The server asks for another step, used by some payment flows | No. The submission is not finished. |
wpformsPageChange | Page button, bubbles up | A multi-page form moves to another page | For funnel steps, not conversions. |
Two details matter here. First, wpformsAjaxSubmitSuccess receives the server response as its second argument. For a message confirmation the response has data.confirmation (the HTML). For page and redirect confirmations it has data.form_id and data.redirect_url, plus data.new_tab when the redirect opens a new tab.
Second, these are jQuery events triggered with jQuery's .trigger(). A jQuery trigger does not dispatch a native DOM event, so document.addEventListener('wpformsAjaxSubmitSuccess', ...) will not hear it. Some tutorials show that native pattern with event.detail. In the current plugin code it stays silent. Bind with jQuery instead, the same way the WPForms developer docs do in their example for running code after an AJAX submission.
Does the WPForms confirmation type change how you track conversions?
Yes, the confirmation type decides which events fire and what the browser does next, so it decides which trigger is reliable. WPForms has three confirmation types: Message, Show Page and Go to URL (Redirect). Combine that with AJAX on or off and you get six cases.
| Confirmation type | AJAX on | AJAX off |
| Message | wpformsAjaxSubmitSuccess fires, then the message replaces the form. Best case for tracking. | Full page reload. The message renders server side in a div with the ID wpforms-confirmation- plus the form ID. Use an Element Visibility trigger on that. |
| Show Page | wpformsAjaxSubmitSuccess fires, then the browser goes to the page URL from redirect_url. | Server sends a redirect. Only a page view trigger on the thank-you page is available. |
| Go to URL | Same as Show Page. If "Open confirmation in new tab" is on, WPForms opens the URL in a new tab and reloads the original page. | Server sends a redirect. Thank-you page trigger only, and only if the URL is on a domain your container runs on. |
Show Page and Go to URL look identical to the listener: both arrive as redirect_url in the response. That is useful, because one listener handles all three types.
Avoid thank-you page triggers when you can. They count reloads, back button visits and anyone who finds the URL. If a client insists on a thank-you page, keep the AJAX listener as the conversion source and treat the page as a nice experience for the visitor, not as the tracking signal.
Also be careful with the selector WPForms itself suggests for element visibility tracking, .wpforms-confirmation-container-full. That class only appears when the global Include Form Styling setting is on "Base and form theme styling". If someone switches it to "Base styling only" or "No styling", the class becomes wpforms-confirmation-container and the trigger silently stops firing. If you must use element visibility on a non-AJAX form, target the ID prefix with [id^="wpforms-confirmation-"], which does not change with the styling setting.
How do you set up the GTM listener for a specific WPForms form ID?
You set it up with one Custom HTML tag that binds a delegated jQuery handler for wpformsAjaxSubmitSuccess and pushes the form ID from the form's data-formid attribute. Each WPForms form renders as <form id="wpforms-form-123" data-formid="123" class="wpforms-validate wpforms-form wpforms-ajax-form">, so the ID is always available.
The listener tag
Create a Custom HTML tag called something like "cHTML - WPForms listener", set Tag firing options to once per page, and fire it on a DOM Ready trigger limited to pages that have forms (or all pages if forms live in the footer or popups).
<script>
(function () {
if (window.wpfGtmListenerBound) { return; }
function bindListener() {
var jq = window.jQuery;
if (!jq) { return false; }
window.wpfGtmListenerBound = true;
jq(document).on('wpformsAjaxSubmitSuccess', 'form.wpforms-form', function (e, response) {
var form = this;
var data = (response && response.data) || {};
var emailInput = form.querySelector('input[type="email"]');
var phoneInput = form.querySelector('input[type="tel"]');
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
event: 'wpforms_submit_success',
wpforms_form_id: String(jq(form).data('formid') || ''),
wpforms_confirmation: data.redirect_url ? 'redirect' : 'message',
wpforms_entry_id: data.entry_id ? String(data.entry_id) : '',
wpforms_email: emailInput ? emailInput.value.trim().toLowerCase() : '',
wpforms_phone: phoneInput ? phoneInput.value.trim() : ''
});
});
jq(document).on('wpformsAjaxSubmitFailed', 'form.wpforms-form', function () {
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
event: 'wpforms_submit_failed',
wpforms_form_id: String(jq(this).data('formid') || '')
});
});
return true;
}
var tries = 0;
(function wait() {
if (bindListener()) { return; }
tries += 1;
if (tries < 40) { setTimeout(wait, 250); }
})();
})();
</script>
Why it is written this way:
- Delegated binding. Binding on
document with the form.wpforms-form selector catches forms that load later, such as forms inside Elementor or block theme popups.
- Read fields before they disappear. The success event fires before WPForms swaps the form for the confirmation message, so the email and phone inputs still exist at that moment.
- jQuery wait loop. Some performance plugins delay jQuery until the first user interaction. The loop retries for about ten seconds so the listener still binds. If a site delays all scripts until interaction, test that the form still submits through AJAX at all before trusting any tracking.
- Guard flag. The flag stops a second copy of the tag from binding twice, which would double every conversion.
- Failure event. The failed event is optional, but it is the fastest way to spot a client form that is quietly rejecting real people.
If you would rather keep the listener in WordPress, you can print the same script with the wpforms_wp_footer_end action, which is the hook WPForms uses in its own developer examples. GTM is easier to audit across many client sites.
The trigger and form ID filter
Create a Custom Event trigger with the event name wpforms_submit_success, as described in Google's custom event trigger documentation. Set it to fire on some custom events where the Data Layer Variable for wpforms_form_id equals the ID of the form that counts. Find the ID in the WPForms forms list or in the shortcode, for example [wpforms id="123"].
Filtering by ID matters on most client sites. A newsletter signup in the footer and a quote request form should not be the same conversion. Use a lookup table variable that maps form IDs to names like quote_request and newsletter, and send that name as a parameter so reports stay readable.
Adding the entry ID
The default AJAX response does not include the entry ID. On WPForms Pro, where entries are saved to the database, you can add it with the wpforms_ajax_submit_success_response and wpforms_ajax_submit_redirect filters. Put this in a code snippets plugin or the child theme:
function augere_wpforms_add_entry_id( $response ) {
$process = wpforms()->obj( 'process' );
if ( $process && ! empty( $process->entry_id ) ) {
$response['entry_id'] = (int) $process->entry_id;
}
return $response;
}
add_filter( 'wpforms_ajax_submit_success_response', 'augere_wpforms_add_entry_id' );
add_filter( 'wpforms_ajax_submit_redirect', 'augere_wpforms_add_entry_id' );
On WPForms Lite, entries are not stored the same way, so the entry ID can be empty. The listener handles that by sending an empty string. The entry ID is worth having because you can pass it as the transaction ID on the Google Ads tag, which lets Google Ads drop duplicates of the same submission.
How do you send WPForms submissions to GA4 and Google Ads?
You send them by firing a GA4 Event tag and a Google Ads Conversion Tracking tag on the wpforms_submit_success trigger, with the form name and entry ID passed as parameters.
GA4
- Tag type. Google Analytics: GA4 Event, using your Google tag or Measurement ID.
- Event name.
generate_lead is Google's recommended lead event and is listed in the GA4 recommended events reference with value, currency and lead_source parameters. Use it for the main lead form and a custom name such as newsletter_signup for the rest.
- Parameters. Send
form_id and form_name. If you have a lead value, send value and currency together.
- Key event. Mark only the events that represent real leads as key events. Our GA4 key events and naming plan covers how to keep that list short across clients.
- No personal data. Never send the email or phone variables to GA4. They exist in the dataLayer only for Google Ads enhanced conversions.
Google Ads
- Conversion Linker. Make sure a Conversion Linker tag fires on all pages, so the click ID from the ad is stored in first-party cookies.
- Conversion tag. Add a Google Ads Conversion Tracking tag with the Conversion ID and Conversion Label from the conversion action in Google Ads.
- Transaction ID. Map the entry ID variable to the transaction ID field when you have it.
- One source of truth. Decide whether Google Ads counts this conversion from the Ads tag or from an imported GA4 key event. If both are set as primary, Google Ads counts the lead twice. Our page on Google Ads counting conversions twice walks through the fix.
If your consent banner blocks tags until a visitor accepts, the listener should still run, because it only pushes to the dataLayer. Let Consent Mode govern the GA4 and Ads tags. See our Consent Mode v2 implementation guide for the setup.
The redirect timing problem
With Show Page or Go to URL confirmations, WPForms changes window.location right after the success event handlers finish. The dataLayer push is synchronous and GTM fires tags on it, but the network requests can be cut off on slow phones when the page unloads. Verify it. Submit the form in Preview mode with the network tab open and "Preserve log" checked, and confirm the GA4 collect request and the Google Ads conversion request both leave the browser. If they do not, switch the form to a Message confirmation, or show a message that includes a link to the next page.
How do you set up enhanced conversions for WPForms?
You set up enhanced conversions for WPForms by giving the Google Ads conversion tag the email (and phone, if collected) that the listener captured at the moment of the successful submission. Google hashes this data before it is sent.
- Turn it on in Google Ads. In the conversion settings, accept the customer data terms and enable enhanced conversions for web, choosing Google Tag Manager as the method.
- Create a User-Provided Data variable. In GTM, create a User-Provided Data variable set to manual configuration and map Email to the
wpforms_email Data Layer Variable and Phone to wpforms_phone.
- Attach it to the conversion tag. On the Google Ads Conversion Tracking tag, enable the option to include user-provided data and select that variable.
- Check the phone format. Google expects phone numbers in E.164 format, such as +15551234567. WPForms phone fields in smart format usually produce this, but a plain text field will not. Normalize it or leave phone out.
- Verify. In Preview mode, open the conversion tag and confirm the user-provided data fields are populated. Then watch the enhanced conversions status in Google Ads over the next days.
Automatic detection, where the tag scans the page for an email, is weak on WPForms. With a Message confirmation, the form has already been replaced by the time some tags look, and with a redirect the fields are gone. Manual mapping from the dataLayer avoids both problems. Google's enhanced conversions for web with Google Tag Manager guide lists the accepted field names if you need to add first name, last name or address. For the bigger picture, including how this differs from enhanced conversions for leads, read our enhanced conversions setup guide.
Why do WPForms conversions get double counted or include spam?
WPForms conversions get double counted when a second tool also reports the same submission, most often the MonsterInsights Forms addon, and they include spam when the form is set to store spam entries, because WPForms still shows the confirmation to those submissions.
MonsterInsights Forms addon overlap
The MonsterInsights Forms addon (Pro plan and higher) tracks WPForms automatically once it is active, with no per-form setup. According to MonsterInsights' own documentation, it sends form_impression when a form is viewed and generate_lead when a form is submitted. If you also send generate_lead from GTM, GA4 gets two lead events per submission. A Google Ads conversion imported from that GA4 event then doubles as well.
Check for it in three places:
- WordPress admin. Look for MonsterInsights under Insights, then Addons, and see whether Forms is active.
- Browser. Submit a test entry with the network tab open and filter on
collect. Two GA4 requests with generate_lead means two senders.
- Measurement ID. If MonsterInsights loads its own Google tag with the same Measurement ID your GTM container uses, page views are likely doubled too, not just leads.
Pick one owner. For agencies that manage tracking for many clients, GTM is the better owner because you can filter by form ID, add enhanced conversions and audit changes in version history. Deactivate the Forms addon, or keep MonsterInsights only for its dashboard reports and make sure only one tool sends the lead event. The same rule applies to Google Site Kit or any other plugin that installs its own Google tag.
How spam settings affect your numbers
Spam protection and conversion tracking interact in ways that are easy to miss. This is what the current WPForms code does:
| Protection | What the visitor sees | Does the success event fire? |
| Cloudflare Turnstile, hCaptcha or reCAPTCHA fails | An error on the form | No. wpformsAjaxSubmitFailed fires instead. |
| Anti-spam protection fails, spam storage off | An error on the form | No. |
| Minimum time to submit or Akismet flags it, spam storage off | An error on the form | No. |
| Any of the checks above fail, "Store spam entries in the database" on | The normal confirmation | Yes. The entry is saved as spam, but the browser treats it as a success. |
| Legacy honeypot field is filled | The normal confirmation | Yes. WPForms fails silently by design, so the bot sees a success. |
Most bots never run JavaScript, so they never trigger your GTM tags. Bots that run a real browser can slip through the last two rows. If a client's Google Ads account shows leads that never reach the inbox or CRM, check whether spam storage is on. You can keep it on for review purposes, but then the browser success event is no longer a clean signal.
The clean signal lives on the server. WPForms runs the wpforms_process_complete action only for entries that were not marked as spam, with the fields, raw entry, form data and entry ID as arguments. That hook is the right place to send a server-side conversion, for example a GA4 event through the Measurement Protocol (see our GA4 Measurement Protocol guide) or a stored click ID you later upload as an offline conversion (see our offline conversion import guide).
How do you track multi-page WPForms forms?
You track multi-page WPForms forms the same way as single page ones: the conversion is still wpformsAjaxSubmitSuccess, which only fires after the final page is submitted and accepted. The Next and Previous buttons do not submit the form, so they never trigger the success event.
If you want to see where people drop off, add a separate funnel event from wpformsPageChange. WPForms passes the new page number, the form and the direction (next or prev) as arguments. Add this inside the bindListener function from the listener tag:
jq(document).on('wpformsPageChange', function (e, page, form, direction) {
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
event: 'wpforms_page_change',
wpforms_form_id: String(jq(form).data('formid') || ''),
wpforms_page: String(page),
wpforms_direction: direction
});
});
Send that to GA4 as a normal event, never as a key event and never to Google Ads. A few things to watch on multi-page forms:
- Do not use the GTM Form Submission trigger. WPForms validates each page in the browser, and the built-in trigger cannot tell a final submit from a blocked one.
- Read fields from the whole form. The email field may sit on page one while the submit button is on page three. The listener reads from the form element, which still contains every page, so this works.
- Watch the CAPTCHA. The CAPTCHA only shows on the last page. If it fails to render there, people get stuck at the end and you see page change events with no success. That pattern in GA4 is a quick way to find a broken form.
Common WPForms tracking mistakes to check
- AJAX is off. The listener never fires on a form that reloads the page. Check each form's Advanced settings, because the toggle is per form, and older or imported forms may still have it off.
- Thank-you page plus listener. Firing the conversion on both the listener and the thank-you page view counts every lead twice.
If a form is still not showing up in GA4 after all this, work through our checklist for GA4 form submissions not tracked.
Getting it fixed for a client
WPForms tracking looks simple until you are dealing with a client site that has five forms, a popup, MonsterInsights, a delayed JavaScript plugin and a Google Ads account importing the same lead twice. The fix is usually the same: one listener, one owner per event, form IDs mapped to names, spam settings reviewed, and enhanced conversions fed from the dataLayer. If you want us to check a client's setup and tell you exactly what is counting wrong, start with a free tracking check.