
Forminator GTM Event Listener
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.
forminator_form_submit Get the code

Copy this into a Custom HTML tag in Google Tag Manager. It pushes lead, add_to_cart, view_item, begin_checkout, purchase to the dataLayer when the GoHighLevel Funnels form is sent.
<script>
/* GoHighLevel Funnel Ecommerce listener by MD Niamul - mdniamul.com
Free GA4 ecommerce events for a GHL funnel: view_item on the sales page,
begin_checkout on the order page and purchase on the thank-you page.
Edit FUNNEL below to match your own funnel step paths. */
(function () {
var FUNNEL = {
currency: 'USD', // used when the page shows only "$"
salesPages: ['/sales'], // view_item
checkoutPages: ['/order'], // begin_checkout
thankYouPages: ['/thank-you'] // purchase
};
window.dataLayer = window.dataLayer || [];
var path = window.location.pathname.replace(//+$/, '') || '/';
function onPage(list) {
for (var i = 0; i < list.length; i++) {
var p = (list[i] || '').replace(//+$/, '') || '/';
if (p === '/' ? path === '/' : (path === p || path.indexOf(p + '/') === 0)) return true;
}
return false;
}
// Reads the price shown on the page, near "Total" first
function readPrice(hints) {
var text = (document.body && document.body.innerText) || '';
var re = /(US$|AU$|CA$|NZ$|$|£|€|USD|AUD|CAD|GBP|EUR)s?([0-9][0-9,]*(?:.[0-9]{1,2})?)/i;
var map = { 'US$': 'USD', 'AU$': 'AUD', 'CA$': 'CAD', 'NZ$': 'NZD', '£': 'GBP', '€': 'EUR' };
function parse(s) {
var m = s.match(re);
if (!m) return null;
var sym = m[1].toUpperCase();
return { value: parseFloat(m[2].replace(/,/g, '')), currency: map[sym] || (sym === '$' ? FUNNEL.currency : sym) };
}
// Use the price closest to a hint word (e.g. "Just $27 Today" wins over "Was $97")
var low = text.toLowerCase();
var reAll = new RegExp(re.source, 'gi');
for (var i = 0; i < (hints || []).length; i++) {
var idx = low.indexOf(hints[i].toLowerCase());
if (idx === -1) continue;
var from = Math.max(0, idx - 40);
var win = text.substring(from, idx + hints[i].length + 60);
var best = null, bestDist = 1e9, m;
reAll.lastIndex = 0;
while ((m = reAll.exec(win))) {
var pos = from + m.index;
var dist = pos < idx ? idx - (pos + m[0].length) : pos - (idx + hints[i].length);
if (dist < bestDist) { bestDist = dist; best = m[0]; }
}
if (best) { var f = parse(best); if (f) return f; }
}
return parse(text) || { value: 0, currency: FUNNEL.currency };
}
function item(price) {
var id = path.replace(/^/+/, '').toLowerCase().replace(/[^a-z0-9]+/g, '-') || 'home';
return { item_id: id, item_name: document.title || id, price: price, quantity: 1 };
}
function push(eventName, value, currency, extra, items) {
var ecommerce = { currency: currency, value: value, items: items || [item(value)] };
for (var k in (extra || {})) ecommerce[k] = extra[k];
window.dataLayer.push({ ecommerce: null }); // clear the last ecommerce object
window.dataLayer.push({ event: eventName, ecommerce: ecommerce, page_path: window.location.pathname });
}
function run() {
if (onPage(FUNNEL.salesPages)) {
var s = readPrice(['today', 'only', 'price']);
push('view_item', s.value, s.currency);
}
if (onPage(FUNNEL.checkoutPages)) {
var c = readPrice(['total', 'today', 'price']);
push('begin_checkout', c.value, c.currency);
try {
sessionStorage.setItem('mdn_ghl_txn', 'TXN-' + new Date().getTime());
sessionStorage.setItem('mdn_ghl_item', JSON.stringify(item(c.value))); // the product from the order page
} catch (e) {}
}
if (onPage(FUNNEL.thankYouPages)) {
var tries = 0;
(function waitForTotal() {
var t = readPrice(['total']);
if (t.value > 0 || tries >= 8) {
if (t.value <= 0) return; // no price found: do not record a $0 sale
var txn = 'TXN-' + new Date().getTime();
try {
txn = sessionStorage.getItem('mdn_ghl_txn') || txn;
sessionStorage.setItem('mdn_ghl_txn', txn); // same ID if the page is reloaded
} catch (e) {}
try {
if (localStorage.getItem('mdn_ghl_sent_' + txn)) return; // reload: already counted
localStorage.setItem('mdn_ghl_sent_' + txn, '1');
} catch (e) {}
var main = null;
try { main = JSON.parse(sessionStorage.getItem('mdn_ghl_item') || 'null'); } catch (e) {}
if (main) main.price = t.value;
push('purchase', t.value, t.currency, { transaction_id: txn }, main ? [main] : null);
return;
}
tries++;
setTimeout(waitForTotal, 500);
})();
}
}
if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', run);
else run();
})();
</script>
This code is also on GitHub with a README and version history: github.com/mdniamul0/ghl-funnel-ecommerce-gtm-listener
lead, add_to_cart, view_item, begin_checkout, purchaselead, add_to_cart, view_item, begin_checkout, purchase, 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: 'purchase',
ecommerce: {
currency: 'USD',
value: 124,
transaction_id: 'TXN-1794023504304',
items: [{ item_id: 'order', item_name: 'Ad Course', price: 124, quantity: 1 }]
},
page_path: '/thank-you'
}FUNNEL: your currency and the paths of your sales page, order page and thank-you page. The path is the part after your domain, for example /order.view_item, begin_checkout and purchase.{{Event}} on those triggers and tick Send Ecommerce data → Data Layer. Put your Google Ads purchase conversion on the purchase trigger.Good to know: the price is read from the page text, so it must be visible on the page. The code never sends a $0 purchase and never counts the same order twice when the thank-you page is reloaded.
Want the full walkthrough? Read my guide on GoHighLevel conversion tracking in GA4 and Google Ads. If you’d rather have it set up for you, see my checkout conversion tracking service or talk to a GoHighLevel conversion tracking specialist.
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.
Yes. It reads the price shown on each funnel page, closest to words like today or total, so you do not type prices into the code. The price must be visible on the page.
No. Each order gets one transaction ID and the code remembers it, so reloads and the back button never add revenue. It also skips the purchase if no total is found.
The free code tracks the sales page, the order page and the purchase. The advanced version also tracks add to cart, leads, payment info and every upsell accepted or declined, and adds them to the purchase.
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 lead, add_to_cart, view_item, begin_checkout, purchase event when the GoHighLevel Funnels 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 GoHighLevel Funnel Tracking done right the first time, message me.