Step 1: Identify the Form Type
Forms on your website can work in different ways. The tracking setup depends on the form type:
Standard Form Submission → The form reloads or redirects after submission.
AJAX Form Submission → The form submits without a page reload.
Button Click-Based Submission → The form is submitted via a button click event.
Step 2: Enable Variables in GTM
Go to GTM > Variables > Configure Built-In Variables, and enable:
Form ID
Form Classes
Click ID
Click Classes
Step 3: Create a Trigger for Form Submission
Depending on the form type, choose the appropriate trigger:
A. Form Submission Trigger (For Standard Forms)
Go to GTM > Triggers > New
Select Form Submission
Enable “Wait for Tags” (for tracking forms in the middle of a session)
Set conditions, e.g., Form ID contains “contact-form”
Save the trigger
B. Click Trigger (For Button-Based Forms)
Go to GTM > Triggers > New
Select Click – All Elements
Enable “Wait for Tags”
Add conditions, e.g., Click ID contains “submit-button”
Save the trigger
C. AJAX Form Submission Trigger
Create a Custom Event Trigger
Set event name to something like “ajaxFormSubmission”
Configure your form’s JavaScript to push an event to the dataLayer:
dataLayer.push({
‘event’: ‘ajaxFormSubmission’,
‘formID’: ‘contact-form’
});
Step 4: Create a GA4 Event Tag
Go to GTM > Tags > New
Select Google Analytics: GA4 Event
Choose your GA4 Configuration Tag
Event Name: form_submission
Set event parameters (optional):
form_id = {{Form ID}}
form_classes = {{Form Classes}}
Select the corresponding Trigger (Form Submission, Click, or AJAX Event)
Save and Publish
Step 5: Test in GTM Preview Mode
Click Preview in GTM
Submit the form and check if the event fires
In GA4, go to Realtime > Events and check if form_submission appears