
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 squarespace_native_form_submit to the dataLayer when the Squarespace Forms form is sent.
<script>
/* Squarespace listener by MD Niamul - mdniamul.com
Fires squarespace_native_form_submit after a Squarespace form block
(or newsletter block) shows its success message. */
(function () {
window.dataLayer = window.dataLayer || [];
var WAIT_MS = 10000;
var watching = {}; // one watcher per form block at a time
var sentAt = {};
// Squarespace adds one of these when the form is sent
var SUCCESS = '.form-submission-text, .sqs-form-submission-text, .form-submission-html, .newsletter-form-submission-text';
var ERROR = '.field-error, .form-error, .form-field-error, [class*="field-error"], [class*="form-error"]';
function blockOf(form) {
return form.closest('.sqs-block-form, .sqs-block-newsletter, .newsletter-block, .form-block, .form-wrapper') || form.parentElement || form;
}
function nameOf(block, form) {
var t = block.querySelector('.form-title, .newsletter-form-header-title, h2, h3');
return (form.getAttribute('aria-label') || (t && t.textContent) || '').replace(/s+/g, ' ').trim().slice(0, 80);
}
function shown(el) {
return !!(el && (el.offsetWidth || el.offsetHeight || el.getClientRects().length));
}
document.addEventListener('submit', function (event) {
var form = event.target;
if (!form || form.tagName !== 'FORM' || !form.closest) return;
var block = form.closest('.sqs-block-form, .sqs-block-newsletter, .newsletter-block, .form-block');
if (!block && !form.closest('.sqs-form, .form-wrapper')) return;
block = block || blockOf(form);
var id = block.id || form.id || 'sqs-form';
if (watching[id]) return; // already waiting for this form's result
var formName = nameOf(block, form);
var hadSuccess = shown(block.querySelector(SUCCESS));
watching[id] = true;
var done = false;
function finish(ok) {
if (done) return;
done = true;
observer.disconnect();
clearTimeout(timer);
watching[id] = false;
if (!ok) return;
var now = new Date().getTime();
if (sentAt[id] && now - sentAt[id] < 5000) return; // one push per submit
sentAt[id] = now;
window.dataLayer.push({
event: 'squarespace_native_form_submit',
form_id: id,
form_name: formName,
page_path: window.location.pathname
});
}
var observer = new MutationObserver(function () {
if (block.querySelector(ERROR)) {
var errs = block.querySelectorAll(ERROR);
for (var i = 0; i < errs.length; i++) { if (shown(errs[i]) && (errs[i].textContent || '').trim()) { finish(false); return; } }
}
var ok = block.querySelector(SUCCESS);
if (ok && shown(ok) && !hadSuccess) finish(true);
});
observer.observe(block, { childList: true, subtree: true, attributes: true, attributeFilter: ['class', 'style', 'hidden'] });
var timer = setTimeout(function () { finish(false); }, WAIT_MS);
}, true);
})();
</script>
This code is also on GitHub with a README and version history: github.com/mdniamul0/squarespace-form-gtm-listener
squarespace_native_form_submitsquarespace_native_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: 'squarespace_native_form_submit',
form_id: 'block-yui_3_17_2_1_1717',
form_name: 'Book a free audit',
page_path: '/contact/'
}squarespace_native_form_submit as the event name.form_name and form_id, so you can tell your forms apart.generate_lead), Google Ads conversion or Meta Pixel Lead event on the squarespace_native_form_submit trigger.Good to know: the event only fires when Squarespace shows its own success message, so failed tries and double clicks are never counted. It works with Squarespace Form blocks and Newsletter blocks.
Want server-side tracking too? Read my guide on Meta Conversions API on Squarespace with GTM, or see my server-side tracking service and GA4 tracking specialist page.
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.
It often fires on every click of the submit button, also when Squarespace shows an error. This listener waits for the Squarespace success message, so only real entries count.
No. It tracks native Squarespace Form and Newsletter blocks. Typeform, JotForm or HubSpot forms in a Code block need their own listener from this library.
Yes. The basic code is free to copy and use on your own and your clients' sites. It fires squarespace_native_form_submit with the form ID and form title.
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 squarespace_native_form_submit event when the Squarespace Forms 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 Squarespace Form Tracking done right the first time, message me.