FreeGoogle Tag Manager recipes

Track WS Form Submissions in Google Tag Manager with this Free GTM Recipe

A free Google Tag Manager recipe that listens for WS Form submissions and gives you a Trigger you can use to fire conversions to Google Ads, Google Analytics and more.

Aaron Beashel
Aaron BeashelUpdated July 20267 min read
The WS Form recipe tag inside Google Tag Manager

Google Tag Manager is a common way to send conversions to Google Ads, Google Analytics, etc when someone submits a form on your website.

The problem is, it's quite difficult to set up. WS Form uses AJAX to save form submissions, which means Google Tag Manager's built-in form submission trigger doesn't work, and you're left having to write custom code to detect the form submission, send an event to the dataLayer, and build a trigger on top of that.

And unless you're a developer or very experienced with Google Tag Manager, you're going to struggle.

Fortunately though, there is a simple solution.

You can simply install this WS Form Conversion Tracking Recipe in your Google Tag Manager account and you'll have everything you need to get basic conversion tracking set up.

What Is a Google Tag Manager Recipe and What's in It?

A recipe is a pre-built set of Google Tag Manager assets (a tag, a trigger, and a variable) that you import in one go instead of building each piece yourself.

This recipe detects successful WS Form submissions, sends a 'Form Submitted' event to Google Tag Manager, and gives you a Trigger you can use to send conversions to Google Analytics, Google Ads, etc.

Here's exactly what's in it:

Custom HTML Tag

Listens for successful WS Form submissions and pushes a 'ws_form_submitted' event to the dataLayer. This is the code that's in it:

The Tag's CodeJavaScript · 67 lines
(function () {
  if (window.__converlyRecipeWsForm) return;
  window.__converlyRecipeWsForm = true;
  window.dataLayer = window.dataLayer || [];

  function fireConversion(formId) {
    window.dataLayer.push({
      event: 'ws_form_submitted',
      form_id: formId || ''
    });
  }

  // Same form-resolution chain the production module uses to find the
  // form element (it just never used it for anything but PII — here we
  // read a generic, non-PII form_id off whatever it resolves to).
  function resolveForm(event, formObject) {
    var formEl = null;
    try {
      if (formObject && formObject.form_canvas_obj && formObject.form_canvas_obj[0]) {
        formEl = formObject.form_canvas_obj[0].querySelector('form.wsf-form');
      }
      if (!formEl && event && event.target) {
        var target = event.target;
        if ((target.tagName || '').toLowerCase() === 'form') {
          formEl = target;
        } else if (target.querySelector) {
          formEl = target.querySelector('form.wsf-form');
        }
      }
      if (!formEl) {
        formEl = document.querySelector('form.wsf-form');
      }
    } catch (e) {
      // non-fatal — fall through with whatever we have (possibly null)
    }
    return formEl;
  }

  // Fire path — WS Form's own jQuery event, fired on `document` once an
  // AJAX submission passes server-side validation. This is the ONLY path
  // that ever fires a conversion.
  var successHooked = false;

  function hookWsFormSuccess() {
    if (successHooked) return true;
    if (typeof jQuery === 'undefined' && typeof $ === 'undefined') return false;

    var jQ = typeof jQuery !== 'undefined' ? jQuery : $;
    jQ(document).on('wsf-success', function (event, formObject) {
      var formEl = resolveForm(event, formObject);
      fireConversion(formEl ? (formEl.id || '') : '');
    });
    successHooked = true;
    return true;
  }

  // Retry hooking on DOMContentLoaded and window load — some sites load
  // jQuery very late.
  if (!hookWsFormSuccess()) {
    document.addEventListener('DOMContentLoaded', function () {
      hookWsFormSuccess();
    });
    window.addEventListener('load', function () {
      hookWsFormSuccess();
    });
  }
})();

Variable

Captures the ID of the form that was submitted so it can be used to filter Tags in GTM. These are its exact settings:

Name

DLV - WS Form ID

Variable Type

Data Layer Variable

Data Layer Variable Name

form_id

Trigger

Fires when the 'ws_form_submitted' event is received, so you can use it as the trigger for any conversion tag. These are its exact settings:

Name

CE - WS Form Submitted

Trigger Type

Custom Event

Event Name

ws_form_submitted

Download This Recipe

Get the ready-to-import file and upload it into Google Tag Manager. Everything shown above (the tag, the variable and the trigger) comes pre-built inside.

Built from Converly's own WS Form detection code

Why It's the Best Recipe Out There

It is built from the same detection code we use in our own conversion tracking product, Converly, just adapted to run inside Google Tag Manager.

Only fires when WS Form confirms the submission went through successfully. Failed submissions are never counted as conversions.
Is regularly tested against a real, live WS Forms instance on the same testing infrastructure we use for Converly, our dedicated conversion tracking tool
Has been used to detect thousands of WS Form submissions by our customers.

How to Use the WS Form GTM Recipe

1

Install the Recipe

Download the recipe using the form above, then import it into your Google Tag Manager container. In GTM, head to Admin, choose Import Container, select the downloaded file, and pick the Merge option so it doesn't overwrite anything already in your container. The listener, variable and trigger are added for you automatically.

Importing the recipe container in Google Tag Manager
2

Configure Your Tags

Now that the recipe is installed, you can use it as a Trigger for your conversion tags. Here are two common examples.

Example 1: Google Analytics

Create a GA4 event tag and set the Trigger that comes with the recipe (called CE - WS Form Submitted) as its firing trigger. Every WS Form submission now sends an event to Google Analytics.

A GA4 event tag using the recipe's trigger

Example 2: Google Ads

Add your Google Ads conversion tag and set it to fire on the Trigger that comes with the recipe (called CE - WS Form Submitted). Conversions will now be sent to Google Ads when someone submits a WS Form on your site.

A Google Ads conversion tag using the recipe's trigger

What This Enables You to Do (and What It Doesn't)

This recipe fires an event in Google Tag Manager whenever a successful WS Form submission is detected. You can use that as a trigger to send conversions to Google Ads, Google Analytics and other tags.

What it does

Sends an Event to GTM

Detects successful WS Form submissions and pushes an event called 'ws_form_submitted' into the dataLayer automatically.

Tells You Which Form Fired

Captures the ID of the form that was submitted. A site with several forms can use the ID as a filter to fire different tags for different forms.

Creates a Trigger in GTM

Gives you a 'Trigger' in Google Tag Manager which you can use as the trigger for any of your conversion tags.

What it doesn't do

Doesn't send the conversion server-side

Conversions are sent to your GA4, Google Ads, etc through the visitor's browser, so ad blockers can block it and browser privacy restrictions can limit tracking to as little as a day.

No Click IDs or Identifiers

It does not capture the Google click ID, Facebook click ID, Meta pixel cookies, IP address or user agent, which ad platforms need for Enhanced Conversions (Google) or a proper Event Match Quality score (Meta).

No Personal Details

The script only fires an event. It does not capture the lead's name, email or phone number and send them to Google Ads, etc. This means you can't use Enhanced Conversions in Google Ads, and you'll get a fairly low Event Match Quality (EMQ) score in Meta.

No Logging or Notifications

You can test it with Tag Assistant when you first set it up, but unless you check every week you have no way of knowing if it breaks.

The Proper Way to Send Conversions to Google Ads, Meta Ads & More

This recipe is fine if you only send events to Google Analytics, which does not accept personal information or IP addresses anyway. But to get a good Event Match Quality (EMQ) score in Meta, or use Enhanced Conversions in Google, you need to send the data server-side, together with the lead's name and email. That is what Converly does.

A Converly workflow sending WS Form conversions to ad platforms

Here's why Converly is the best way to send conversions to Google Ads, Meta Ads, Microsoft Ads, ChatGPT Ads, LinkedIn Ads, etc.

Easy to set up

Converly gives you a simple drag-and-drop builder you can use to build a Conversion Flow. Simply select a trigger (like a WS Form being submitted) and then select your actions (like sending a conversion to Google Ads). No custom code, no complex configuration.

Sends Data Server-Side

Converly sends conversions directly from its servers to Google, Meta, ChatGPT, etc., so ad blockers and privacy restrictions can't stop the conversions from being delivered.

Sends More Data

It captures the lead's name, email and phone plus the Google and Facebook click IDs, IP address and user agent, and sends them with every conversion. That enables Enhanced Conversions in Google Ads, or gives you an Event Match Quality (EMQ) score of 9 or 10 in Meta.

Full Conversion Log & Email Notifications

See every conversion, what was captured, what was sent to each platform and whether it was received. You can even set up email alerts so tracking can't break without you knowing.

Supports Multiple Tools & Destinations

Detects submissions across 100+ form, scheduling and chat tools and sends conversions to 20+ destinations including Google Ads, Meta, LinkedIn, ChatGPT, Microsoft and TikTok. So if you ever add a new tool to your website or start advertising on a new platform, it's just a few clicks.

Provides Free Support

Our team has 20 years of experience in conversion tracking and analytics and is here to help whenever you need it. With Google Tag Manager, you're on your own.

Start Your Free Trial

Start a 14-day free trial and track your conversions the proper way. No code, no complicated configuration.

About the author

Aaron Beashel
Aaron Beashel

Aaron is the founder of Converly. With over 15 years of experience in digital marketing and SaaS, he's passionate about helping businesses track and optimise their ad conversions.

Start your free trial

Easily send conversions to your ad platforms and analytics tools.
No code required.