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
ninjaFormSubmissionKey variable
NFformIDNinja 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
| Name | DL Key | Example |
|---|---|---|
| DLV – NF Form ID | NFformID | "1" |
GA4 Mapping
| GA4 Event | Parameter | Value |
|---|---|---|
generate_lead | form_id | DLV – NF Form ID |
generate_lead | method | "ninja_forms" |
Debugging
| Problem | Cause | Fix |
|---|---|---|
| Event not firing | jQuery load order | Change trigger to Window Loaded |
NFformID undefined | Variable key wrong | Use exactly NFformID |
Best Practices
- Create a GTM Lookup Table to map form IDs to names
- Use separate conversion actions in Google Ads for high-value forms
- Combine with GA4's
generate_leadevent for CRM attribution