Free resource · 12 listeners

Free GTM Listener Library

Copy-paste Google Tag Manager listeners for the forms, booking tools and contact buttons that GTM's built-in triggers miss. Each one fires only on a real success, pushes one clean dataLayer event, and comes with the trigger setup and a test checklist.

Short answer

How to use a listener in Google Tag Manager

  1. In GTM, create a Custom HTML tag and paste the listener.
  2. Fire it on All Pages (or only the pages where the tool appears). Make sure it fires once per page.
  3. Create a Custom Event trigger using the listener's event name (for example calendly_booked).
  4. Attach your GA4 event (generate_lead), Google Ads conversion and Meta Lead to that trigger.
  5. Test in GTM Preview and GA4 DebugView: one real submission should create exactly one event.
The library

Pick your tool, copy the listener

HubSpot forms

forms

Listens for HubSpot's own success messages. Keep only the block that matches your form type (legacy embed or new HubSpot forms), so one submission is never counted twice.

dataLayer event: hubspot_form_submit

<script>
  // Legacy / embedded HubSpot forms
  window.addEventListener('message', function (e) {
    if (e.data && e.data.type === 'hsFormCallback' && e.data.eventName === 'onFormSubmitted') {
      window.dataLayer = window.dataLayer || [];
      window.dataLayer.push({ event: 'hubspot_form_submit', form_id: e.data.id });
    }
  });
  // New HubSpot forms (2024+)
  window.addEventListener('hs-form-event:on-submission:success', function () {
    window.dataLayer = window.dataLayer || [];
    window.dataLayer.push({ event: 'hubspot_form_submit' });
  });
</script>

Full setup guide →

Calendly (embedded)

booking

Calendly embeds send a window message when a meeting is booked. The listener checks the origin so other iframes can't fire it.

dataLayer event: calendly_booked

<script>
  window.addEventListener('message', function (e) {
    if (e.origin !== 'https://calendly.com') return;
    if (e.data && e.data.event === 'calendly.event_scheduled') {
      window.dataLayer = window.dataLayer || [];
      window.dataLayer.push({ event: 'calendly_booked' });
    }
  });
</script>

Full setup guide →

Tally forms (embedded)

forms

Tally embeds post a Tally.FormSubmitted message to the page when a form is submitted.

dataLayer event: tally_submit

<script>
  window.addEventListener('message', function (e) {
    if (typeof e.data !== 'string' || e.data.indexOf('Tally.FormSubmitted') === -1) return;
    try {
      var msg = JSON.parse(e.data);
      window.dataLayer = window.dataLayer || [];
      window.dataLayer.push({ event: 'tally_submit', form_id: msg.payload && msg.payload.formId });
    } catch (err) {}
  });
</script>

Full setup guide →

Typeform (Embed SDK)

forms

Typeform runs in an iframe, so use the Embed SDK's onSubmit callback (or data-tf-on-submit="jmTypeformSubmit" on the embed) and push from there.

dataLayer event: typeform_submit

<script>
  // Add data-tf-on-submit="jmTypeformSubmit" to your Typeform embed element
  window.jmTypeformSubmit = function (data) {
    window.dataLayer = window.dataLayer || [];
    window.dataLayer.push({ event: 'typeform_submit', response_id: data && data.responseId });
  };
</script>

Full setup guide →

Contact Form 7 (WordPress)

forms

Contact Form 7 fires a wpcf7mailsent browser event only after the email was sent successfully, so validation errors never count.

dataLayer event: cf7_submit

<script>
  document.addEventListener('wpcf7mailsent', function (e) {
    window.dataLayer = window.dataLayer || [];
    window.dataLayer.push({ event: 'cf7_submit', form_id: e.detail && e.detail.contactFormId });
  }, false);
</script>

Full setup guide →

WPForms (AJAX on)

forms

With AJAX submission turned on, WPForms triggers wpformsAjaxSubmitSuccess on success. Needs jQuery, which WordPress loads by default.

dataLayer event: wpforms_submit

<script>
  (function ($) {
    if (!$) return;
    $(document).on('wpformsAjaxSubmitSuccess', function (e) {
      var form = e.target && e.target.closest ? e.target.closest('form') : null;
      window.dataLayer = window.dataLayer || [];
      window.dataLayer.push({ event: 'wpforms_submit', form_id: form ? form.getAttribute('data-formid') : undefined });
    });
  })(window.jQuery);
</script>

Full setup guide →

Gravity Forms (AJAX)

forms

Gravity Forms triggers gform_confirmation_loaded after an AJAX submission shows its confirmation message.

dataLayer event: gravity_submit

<script>
  (function ($) {
    if (!$) return;
    $(document).on('gform_confirmation_loaded', function (e, formId) {
      window.dataLayer = window.dataLayer || [];
      window.dataLayer.push({ event: 'gravity_submit', form_id: formId });
    });
  })(window.jQuery);
</script>

Full setup guide →

Elementor Pro forms

forms

Elementor Pro forms trigger a submit_success jQuery event when the form was accepted.

dataLayer event: elementor_submit

<script>
  (function ($) {
    if (!$) return;
    $(document).on('submit_success', function (e) {
      var form = e.target;
      window.dataLayer = window.dataLayer || [];
      window.dataLayer.push({ event: 'elementor_submit', form_name: form && form.getAttribute ? form.getAttribute('name') : undefined });
    });
  })(window.jQuery);
</script>

Full setup guide →

Ninja Forms

forms

Ninja Forms triggers nfFormSubmitResponse after a successful submission, with the form ID in the response.

dataLayer event: ninja_submit

<script>
  (function ($) {
    if (!$) return;
    $(document).on('nfFormSubmitResponse', function (e, response) {
      window.dataLayer = window.dataLayer || [];
      window.dataLayer.push({ event: 'ninja_submit', form_id: response && response.id });
    });
  })(window.jQuery);
</script>

Full setup guide →

Webflow forms

forms

Webflow submits forms in the background and shows the .w-form-done success box. This watches for it to appear, so failed submissions don't count.

dataLayer event: webflow_form_submit

<script>
  (function () {
    var seen = new WeakSet();
    function check() {
      document.querySelectorAll('.w-form-done').forEach(function (el) {
        if (seen.has(el) || el.offsetParent === null) return;
        seen.add(el);
        var form = el.parentElement && el.parentElement.querySelector('form');
        window.dataLayer = window.dataLayer || [];
        window.dataLayer.push({ event: 'webflow_form_submit', form_name: form ? (form.getAttribute('data-name') || form.id) : undefined });
      });
    }
    new MutationObserver(check).observe(document.body, { attributes: true, subtree: true, attributeFilter: ['style', 'class'] });
  })();
</script>

Full setup guide →

Klaviyo sign-up forms

forms

Klaviyo forms dispatch a klaviyoForms event on the window. Only the submit type is a real sign-up.

dataLayer event: klaviyo_form_submit

<script>
  window.addEventListener('klaviyoForms', function (e) {
    if (e.detail && e.detail.type === 'submit') {
      window.dataLayer = window.dataLayer || [];
      window.dataLayer.push({ event: 'klaviyo_form_submit', form_id: e.detail.formId });
    }
  });
</script>

Full setup guide →

Phone, email & WhatsApp clicks

clicks

One listener for tel:, mailto: and WhatsApp links. Use these as secondary conversions only: a click is not a lead.

dataLayer event: contact_click

<script>
  document.addEventListener('click', function (e) {
    var a = e.target.closest ? e.target.closest('a[href]') : null;
    if (!a) return;
    var href = a.getAttribute('href') || '';
    var type = /^tel:/i.test(href) ? 'phone' : /^mailto:/i.test(href) ? 'email'
      : /wa\.me|api\.whatsapp\.com/i.test(href) ? 'whatsapp' : null;
    if (!type) return;
    window.dataLayer = window.dataLayer || [];
    window.dataLayer.push({ event: 'contact_click', contact_type: type, link_location: location.pathname });
  }, true);
</script>

Full setup guide →

Before you go live

Test checklist

  • Submit once with an error: nothing should fire.
  • Submit once correctly: exactly one event in GTM Preview.
  • Check GA4 DebugView and Meta Test Events receive it.
  • In Google Ads, only one primary conversion per lead.
  • Never push names, emails or phone numbers into GA4 parameters.

Stuck, or setting this up across many client sites? I do it white-label for agencies. See agency partnership or request a tracking audit.

FAQ

Questions about GTM listeners

What is a GTM listener?

A small piece of JavaScript, added in Google Tag Manager as a Custom HTML tag, that listens for an event a tool sends (a form success, a booking, a click) and pushes a clean dataLayer event. GTM triggers and tags then fire from that event.

Why not use GTM's built-in Form Submission trigger?

Most modern forms submit in the background or run inside iframes, so the built-in trigger either misses them or fires on failed submissions. Listening for the tool's own success event is more reliable.

Can I use these listeners for free?

Yes. Copy them into your own or your clients' GTM containers. A link back to this page is appreciated but not required.

Do these work with Consent Mode v2?

Yes. The listeners only push dataLayer events. Whether GA4, Google Ads or Meta tags then fire is still controlled by your tags' consent settings.

Do I need one listener per page?

Fire each listener on the pages where that tool appears, or on all pages if it appears in a site-wide popup or footer. Make sure each listener tag fires only once per page, or every conversion is counted twice.

Using this library in a post, course or client handbook? Please link to jobairmahmud.com/gtm-listener-library/.