Objective
Track form submissions from the resource section popup as a GA4 event (generate_lead) using Google Tag Manager, even though there is no page reload or thank-you page.
Why This Approach?
Since this is a JavaScript-powered popup form, GTM’s default Form Submission trigger likely won’t detect it.
👉 The most accurate solution: fire a custom GTM event using dataLayer.push() after a successful submission.
Step 1: Add dataLayer.push() to Your Form Logic
Ask your developer (or update the Gatsby form component) to push an event after successful submission, like this:
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
event: “generate_lead”,
form_location: “popup_resource_form”
});
Place this code after the form data has been successfully submitted and accepted, not just when the submit button is clicked.
Step 2: Create a Custom Event Trigger in GTM
- Go to GTM
- In the left menu, go to Triggers
- Click New
- Name it: Custom – generate_lead (Resource Popup)
- Choose Trigger Type → Custom Event
- Set Event name to: generate_lead
- Choose: All Custom Events
- Click Save
Step 3: Create a GA4 Event Tag
- Go to Tags → Click New
- Name it: GA4 – generate_lead (Resource Download)
- Tag Configuration → Select GA4 Event
- Select your GA4 Configuration Tag
- Set Event Name to: generate_lead
- Add optional parameters (for context):
form_location : popup_resource_form
resource_type : whitepaper
Step 4: Link the Trigger to the Tag
- Scroll to Triggering
- Select: Custom – generate_lead (Resource Popup)
- Click Save
Step 5: Preview and Test
- Click Preview in GTM
- Open the Resource page on your website
- Click Download this file → Form appears
- Fill out and submit the form
- In the Tag Assistant debug window, confirm:
- Event generate_lead appears in the timeline
- GA4 event tag fires successfully
- Event parameters (form_location, resource_type) show up correctly
Step 6: Publish
Once confirmed, click Submit → Publish in GTM
Name the version: GA4 Event – Resource Popup Submission
Result
Each time a user submits the popup resource form, a GA4 event generate_lead is triggered, helping you:
- Track downloads
- Attribute leads to specific campaigns or files
- Build conversion-based audiences in GA4