Skip to main content

Ninja Forms GTM Event Listener

Track Ninja Forms submissions in Google Tag Manager. Capture NFformID and fire GA4, Google Ads, and Meta Pixel on ninjaFormSubmission.

ninja-formswordpressformsgtmga4lead-generationjquery

Event fired

ninjaFormSubmission

Key variable

NFformID

Ninja Forms

Overview

Ninja Forms is a flexible drag-and-drop form builder for WordPress. This listener uses jQuery's nfFormSubmitResponse event, fired by Ninja Forms after a successful submission, to push conversion data into the GTM dataLayer.

Event fired: ninjaFormSubmission Variable: NFformID Credit: Chris Berkley

Why Use This Listener

Ninja Forms submits via AJAX. The native GTM Form Submit trigger fires on button click, not on confirmed submission. This listener fires only after Ninja Forms confirms the response from the server.

Common Use Cases

  • Track lead form and contact form completions
  • Differentiate conversions across multiple Ninja Forms
  • Fire Google Ads conversion tags on form confirmation
  • Build GA4 custom audiences from form submitters

Installation

html
<!-- GTM Custom HTML Tag: Ninja Forms Listener -->
<script>
jQuery(document).ready(function() {
  jQuery(document).on('nfFormSubmitResponse', function(event, response, id) {
    window.dataLayer = window.dataLayer || [];
    window.dataLayer.push({
      'event': 'ninjaFormSubmission',
      'NFformID': response.id
    });
  });
});
</script>

Fire on: All Pages (DOM Ready). Requires jQuery (included by WordPress).

Data Layer Output

json
{
  "event": "ninjaFormSubmission",
  "NFformID": "1"
}

GTM Setup

Trigger

Type: Custom Event Event Name: ninjaFormSubmission

Variable

NameDL KeyExample
DLV – NF Form IDNFformID"1"

GA4 Mapping

GA4 EventParameterValue
generate_leadform_idDLV – NF Form ID
generate_leadmethod"ninja_forms"

Debugging

ProblemCauseFix
Event not firingjQuery load orderChange trigger to Window Loaded
NFformID undefinedVariable key wrongUse exactly NFformID

Best Practices

  1. Create a GTM Lookup Table to map form IDs to names
  2. Use separate conversion actions in Google Ads for high-value forms
  3. Combine with GA4's generate_lead event for CRM attribution

Related Listeners