
WPForms GTM Event Listener
Free WPForms tracking code for GTM. Fires wpform_submit once per accepted entry, with AJAX on or off, in popups and with redirects. GA4 and Google Ads ready.
wpform_submit Get the code
Free Forminator tracking code for GTM. Fires forminator_form_submit once per saved entry, for AJAX and Page Reload forms, popups and redirects. GA4 ready.

Copy this into a Custom HTML tag in Google Tag Manager. It pushes forminator_form_submit to the dataLayer when the Forminator form is sent.
<script>
/* Forminator listener by MD Niamul - mdniamul.com
Fires forminator_form_submit once per Forminator form that Forminator
accepts. AJAX forms: Forminator's own 'forminator:form:submit:success'
event. Page reload forms: the page Forminator sends back (its success
message, or the redirect URL).
Works when GTM loads before jQuery, catches forms that load late
(popups, tabs, page builders), and never sends what people typed. */
(function () {
if (window.__mdnForminatorBasic) return; // tag fired twice: keep one copy
window.__mdnForminatorBasic = true;
window.dataLayer = window.dataLayer || [];
var EVENT = 'forminator_form_submit', KEY = 'mdn_fm_pending', last = {}, posting = null;
function push(id, type, confirmation) {
var k = id + '|' + type;
if (!id || (last[k] && new Date().getTime() - last[k] < 1500)) return; // one push per submit
last[k] = new Date().getTime();
window.dataLayer.push({ event: EVENT, form_id: String(id), submit_type: type, confirmation_type: confirmation, page_path: window.location.pathname });
}
(function bind(tries) {
var $ = window.jQuery;
if (!$ || !$.fn || !$.fn.on) { if (tries < 300) setTimeout(function () { bind(tries + 1); }, 100); return; }
// 1) AJAX forms. Forminator triggers this on the form only when the
// server saved the entry, before any redirect.
$(document).on('forminator:form:submit:success', function (e, formData, response) {
try {
var form = e.target;
if (!form || !form.getAttribute) return;
var d = (response && response.data) || {};
push(form.getAttribute('data-form-id'), 'ajax', d.url ? 'redirect' : 'message');
} catch (err) {}
});
// 2) Page reload forms: Forminator's checks passed, the page is posting.
$(document).on('before:forminator:form:submit', function (e) {
if (posting && posting.form === e.target) posting.sent = true;
});
})(0);
document.addEventListener('submit', function (e) {
var f = e.target;
if (!f || !f.matches || !f.matches('form.forminator-custom-form:not(.forminator_ajax)')) return;
posting = { form: f, native: false, sent: false };
setTimeout(function () { if (posting && posting.form === f && !e.defaultPrevented) posting.native = true; }, 0);
}, true);
window.addEventListener('pagehide', function () {
if (!posting || !(posting.native || posting.sent)) return;
try { sessionStorage.setItem(KEY, JSON.stringify({ id: posting.form.getAttribute('data-form-id'), at: new Date().getTime() })); } catch (err) {}
});
var p = null;
try { p = JSON.parse(sessionStorage.getItem(KEY) || 'null'); sessionStorage.removeItem(KEY); } catch (err) {}
if (p && p.id && new Date().getTime() - p.at < 5 * 60 * 1000) {
var check = function () {
// Accepted: Forminator shows its success message, or the visitor is
// on a page without that form (redirect). Rejected: the form comes
// back with an error message.
var box = document.getElementById('forminator-module-' + p.id);
if (!box) push(p.id, 'reload', 'redirect');
else if (box.querySelector('.forminator-response-message.forminator-success')) push(p.id, 'reload', 'message');
};
if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', check); else check();
}
})();
</script>
This code is also on GitHub with a README and version history: github.com/mdniamul0/forminator-gtm-listener
forminator_form_submitforminator_form_submit, use it on your GA4, Google Ads or Meta tag, then Preview and Publish.After you install the code and send a test entry, this is the data that shows up in GTM. You don’t need to paste it anywhere. Use it to check the listener works and to create Data Layer Variables such as form_id.
{
event: 'forminator_form_submit',
form_id: '118',
submit_type: 'ajax',
confirmation_type: 'message',
page_path: '/contact/'
}forminator_form_submit. To track one form only, add the condition form_id equals your form’s ID (the number in the Forminator shortcode).form_id, submit_type (ajax or reload) and confirmation_type (message or redirect).generate_lead), Google Ads conversion or Meta Pixel Lead event on the forminator_form_submit trigger.forminator_form_submit shows up once. Page Reload forms show the event on the page you land on after the submit. Then publish your container.Good to know: AJAX forms use Forminator’s own forminator:form:submit:success event, and Page Reload forms are confirmed on the result page (Forminator’s success message, or your redirect URL), so the event only fires when Forminator saves the entry. The free code never sends what people typed, so nothing personal reaches GA4.
Want the full GA4 setup? Read my guide on WordPress form tracking in GA4 with GTM. Using another form plugin? See the WPForms listener. If you’d rather have it done for you, see my Google Ads tracking specialist page and my server-side tracking service.
The free code tells GTM that a lead happened. The advanced code tells your ad platforms who the lead is and where they came from.
| What you get | Basic Free | Advanced Paid |
|---|---|---|
| Fires only on a successful submit or booking | Yes | Yes |
| Form or platform ID in the dataLayer | Yes | Yes |
| UTM source, medium, campaign, term and content | No | Yes |
| Ad click IDs (gclid, wbraid, gbraid, fbclid, ttclid, msclkid) | No | Yes |
| SHA-256 hashed email, phone and name | No | Yes |
| First-party cookies (_fbp, _fbc, _ga, _gcl_aw) | No | Yes |
| Device, browser and visitor location | No | Yes |
| event_id for Pixel and CAPI deduplication | No | Yes |
| Ready for Google Ads Enhanced Conversions and Meta CAPI | No | Yes |
| Install help from MD Niamul | No | Yes |
Built for agencies and brands that run paid ads. Every lead carries the data that Meta, Google Ads, TikTok and GA4 need to match the person and credit the right campaign.
One-time price. Start with the code, or let me set everything up for you.
You install it yourself
We set it up together
I install and test it
Browser + server tracking
Stape.io plan paid separately
Server-side: Server-side tracking runs on Stape.io. The Stape plan is not included: you pay Stape directly (they have a free plan for small sites). I set it up on your account. Get Stape (global) · Stape EU server
One-time prices in USD. You pay me directly and get an invoice in your client portal.
Not sure which one fits? Message me and I will tell you what you need.
Already bought the advanced code? Get it in your client portal.
Many scripts call jQuery the moment GTM runs. GTM usually loads before jQuery, and pages without a form may not load jQuery at all, so the code breaks and tracks nothing. This code waits for jQuery and stays quiet on pages without it.
Yes. The submit is remembered only when Forminator really sends the form, and the event goes out on the page Forminator sends back, only when the entry was saved. GTM must load on that page.
A Page Reload form that redirects to another domain: that page is on a different site, so the event can't be finished there. Also, Forminator shows its normal success message when its honeypot catches a bot, so a bot that runs JavaScript could still count. Real bots rarely do.
Message me on WhatsApp. After payment I add it to your client portal with the code, a setup video, a PDF guide and a GTM import file.
Yes. The basic code on this page is free to copy and use on your own or your clients’ sites. It fires the forminator_form_submit event when the Forminator form is sent.
The basic version only tells GTM that a lead happened. The advanced version also sends UTM values, ad click IDs, hashed email and phone, first-party cookies, device and location data and an event_id, so Meta CAPI, Google Ads Enhanced Conversions and GA4 get much better data.
Message me on WhatsApp, book a call or use the contact form. It is a paid, one-time purchase, and I can install it for you if you like.
No. The listener runs inside Google Tag Manager and listens for the form’s own success signal. You don’t need to edit the form or your theme.
💬 Want this implemented without mistakes?
I’ve completed 850+ projects for 600+ businesses and 15+ agencies, helping clients generate $11M+ in revenue with accurate client-side & server-side tracking and business automation.
⮏ My core services include:
⨭ GoHighLevel Automation — build CRM pipelines, WhatsApp automation, AI voice workflows & automated follow-ups end-to-end.
⨭ AI Agent Automation — deploy AI chatbots & agents for 24/7 lead qualification and support.
⨭ Paid Ads Management — Google Ads, Meta Ads.
⨭ Full Stack SEO/GEO/AEO Manager.
⨭ CRO-Focused Web Development — Landing Pages on WordPress, Shopify, Wix, Squarespace.
⨭ Google Tag Manager (GTM) — manage data layers & (Marketing platform Tag, Trigger & Variables).
⨭ Custom Code by GTM — HTML, CSS & JavaScript for advanced marketing platform tracking.
⨭ Server-Side Tracking — recover data lost to ITP & ad blockers (Official Stape Partner).
⨭ Google Analytics 4 (GA4) — visualize customer journeys.
⨭ Multi-Channel CAPI — Facebook, TikTok, Pinterest & Snapchat Conversion API & Klaviyo email marketing tools.
⨭ Third Party Checkout Conversion Tracking — Shopify, Stripe, GoKwik, Shiprocket, PayPal or more.
⨭ Google Consent Mode (GCM) — maintain GDPR compliance.
⨭ Marketing Automation — streamline workflows (Zapier/n8n/Make).
⨭ CRM Conversion Tracking — link offline sales to ads.
⨭ Tag Management — GTM & Third-Party Checkout Tracking.
⨭ Offline & CRM Tracking — HubSpot, Salesforce, Zoho, Pipedrive, Odoo, Webhook & Sheet.
⨭ Advanced Analytics — GA4, Google Looker Studio & BigQuery (SQL) for deep data visualization.
If you want your Forminator Tracking done right the first time, message me.