Gravity Forms GTM Event Listener
Track Gravity Forms submissions in Google Tag Manager. Fire GA4, Google Ads, and Meta Pixel on successful Gravity Form submissions using the gform_confirmation_loaded event.
Event fired
formSubmissionSuccessGravity Forms
Overview
Gravity Forms is a premium WordPress form plugin used for complex multi-step forms, conditional logic, and payment integrations. This listener uses jQuery's gform_confirmation_loaded event, which Gravity Forms fires when the confirmation message renders after a successful submission, to push a clean conversion event into the GTM dataLayer.
Event fired: formSubmissionSuccess
Trigger type: Custom Event
Credit: Julius Fedorovicius (Analytics Mania)
Why Use This Listener
Gravity Forms shows a confirmation message after submission. The gform_confirmation_loaded event fires at exactly this moment, making it the most reliable conversion signal available. GTM's built-in Form Submit trigger fires on button click (before validation), which leads to inflated conversion counts.
| Native GTM Trigger | This Listener |
|---|---|
| Fires on button click (before success) | Fires only after confirmation renders |
| No form ID available | Captures formID for segmentation |
| High false-positive rate | Zero false positives |
| Can't distinguish Ajax vs standard forms | Works with Gravity Forms' Ajax mode |
Common Use Cases
- Track confirmed lead submissions on contact and quote request forms
- Measure form completion rates by form ID
- Fire Google Ads GCLID-based conversions on form confirmation
- Build GA4 funnel steps: page view → form view → form start → form submit
- Create remarketing audiences of form submitters in Google Ads and Meta
- A/B test different form layouts and compare conversion rates
How It Works
Gravity Forms uses jQuery's event system. When the confirmation is displayed, it triggers gform_confirmation_loaded with the formId passed as an event argument. The listener binds to this event and pushes the formSubmissionSuccess event to the dataLayer.
flowchart TD
A[User Submits Form] --> B{GF Validation}
B -->|Fail| C[Show Inline Errors]
B -->|Pass| D[Process Submission]
D --> E[Show Confirmation Message]
E --> F[gform_confirmation_loaded fires]
F --> G[dataLayer.push formSubmissionSuccess]
G --> H[GTM Trigger Fires]
H --> I[GA4 / Ads / Meta Tags Fire]GTM Setup Guide
Step 1: Create the Custom HTML Tag
- GTM → Tags → New → Custom HTML
- Name:
cHTML – Gravity Forms Listener - Paste the code below
- Trigger: All Pages or DOM Ready
Step 2: Create the Custom Event Trigger
- Triggers → New → Custom Event
- Event name:
formSubmissionSuccess - Fires on: All Custom Events (or add condition for specific form)
Step 3: Create DataLayer Variable
| Variable Name | DL Key | Purpose |
|---|---|---|
| DLV – GF Form ID | formID | Unique Gravity Form identifier |
Step 4: Connect Your Tags
Add the formSubmissionSuccess trigger to your GA4 Event, Google Ads Conversion, or Meta Pixel tag.
Installation
<!-- GTM Custom HTML Tag: Gravity Forms Listener -->
<!-- Trigger: All Pages -->
<script>
jQuery(document).ready(function() {
jQuery(document).bind('gform_confirmation_loaded', function(event, formID) {
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
'event': 'formSubmissionSuccess',
'formID': formID
});
});
});
</script>Requirement: jQuery must be loaded before this tag fires. Gravity Forms includes jQuery by default, but if you're deferring scripts, use Window Loaded as the firing trigger instead of DOM Ready.
Example Implementation
Multi-Form Tracking (Different Events per Form)
jQuery(document).ready(function() {
jQuery(document).bind('gform_confirmation_loaded', function(event, formID) {
window.dataLayer = window.dataLayer || [];
var eventName = 'formSubmissionSuccess';
var formType = 'general';
// Map form IDs to descriptive names
var formMap = {
1: { name: 'contact', type: 'lead' },
2: { name: 'demo_request', type: 'high_intent' },
3: { name: 'newsletter', type: 'awareness' }
};
var formInfo = formMap[formID] || { name: 'unknown', type: 'general' };
window.dataLayer.push({
'event': eventName,
'formID': formID,
'formName': formInfo.name,
'formType': formInfo.type
});
});
});Data Layer Output
{
"event": "formSubmissionSuccess",
"formID": 1
}With extended version:
{
"event": "formSubmissionSuccess",
"formID": 2,
"formName": "demo_request",
"formType": "high_intent"
}Trigger Configuration
All Gravity Forms
Trigger Type: Custom Event
Event Name: formSubmissionSuccess
Specific Form Only
Trigger Type: Custom Event
Event Name: formSubmissionSuccess
Condition: DLV – GF Form ID | equals | 2
Variables to Capture
| Variable Name | DL Key | Example |
|---|---|---|
| DLV – GF Form ID | formID | 1 |
| DLV – GF Form Name | formName | "demo_request" |
GA4 Mapping Recommendations
| GA4 Event | Parameter | Source |
|---|---|---|
generate_lead | form_id | DLV – GF Form ID |
generate_lead | form_name | DLV – GF Form Name |
generate_lead | method | "gravity_forms" |
Debugging
GTM Preview Mode
- Enable Preview mode in GTM
- Submit a Gravity Form on your site
- Check for
formSubmissionSuccessin the Events panel - Confirm
formIDis correct
Common Issues
| Problem | Cause | Fix |
|---|---|---|
| Event not firing | jQuery not available | Change trigger to Window Loaded |
formID is undefined | Variable key wrong | Use exactly formID (capital ID) |
| Event fires twice | Duplicate GTM containers | Check for two GTM snippets |
| Not firing on Ajax forms | Listener attached before Gravity Forms JS loads | Use Window Loaded trigger |
Best Practices
- Map form IDs in a Lookup Table, In GTM, create a Lookup Table variable that converts numeric IDs to human-readable names (e.g.,
1→"Contact Form") - Use per-form conversion actions, In Google Ads, create separate conversion actions for high-intent vs. low-intent forms
- Don't track newsletter signups the same as demo requests, Create separate GA4 events:
newsletter_signupanddemo_request - Combine with Gravity Forms entry notifications, For PII compliance, avoid pushing full field data to the dataLayer
Performance Considerations
- Adds one jQuery event listener to the document on DOM Ready
- Negligible performance impact
- Only fires after confirmation renders, so no false positives
Related Listeners
FAQ
Q: Does this work with multi-page (multi-step) Gravity Forms?
A: Yes, gform_confirmation_loaded only fires after the final page is submitted successfully.
Q: Does it work with Gravity Forms payment integrations? A: The event fires when the confirmation is shown. For payment forms, test whether the confirmation appears after payment processing.
Q: Can I capture field values like email?
A: The standard listener doesn't capture field values. You can access them via jQuery('#gform_1 input[name="input_3"]').val(), but be careful with GDPR/consent obligations.
Q: What if I have 20+ forms?
A: Use one listener and a GTM Lookup Table to map all form IDs to names. Create one GA4 event with form_id as a parameter rather than 20 separate events.