Tracking form submissions using Google Tag Manager (GTM) is a common task to capture user interactions on your website. Here is a step-by-step guide to set it up:
Step 1: Enable Built-in Variables
Log in to GTM and go to your workspace.
Click on “Variables” in the left-hand menu.
Click on “Configure” under Built-in Variables.
Enable the following variables:
Form ID
Form Classes
Form Element
Form Target
Form URL
Step 2: Create a Trigger for Form Submission
Go to “Triggers” in the left-hand menu.
Click on “New” to create a new trigger.
Name your trigger something like “Form Submission Trigger”.
Click on “Trigger Configuration” and select “Form Submission”.
Choose when the trigger should fire. You can choose “All Forms” or “Some Forms”. If you choose “Some Forms”, specify the conditions based on form attributes (e.g., Form ID, Form Classes).
Click “Save”.
Step 3: Create a Tag to Send Data to Google Analytics
Go to “Tags” in the left-hand menu.
Click on “New” to create a new tag.
Name your tag something like “GA Form Submission”.
Click on “Tag Configuration” and select “Google Analytics: Universal Analytics” or “Google Analytics: GA4 Configuration” depending on which version you are using.
Set the Track Type to “Event”.
Configure your event tracking parameters:
Category: Form
Action: Submission
Label: {{Page URL}} (or any other variable that identifies the form)
Set the Google Analytics settings variable.
Click on “Triggering” and select the trigger you created in Step 2 (“Form Submission Trigger”).
Click “Save”.
Step 4: Publish Your Changes
Click on “Submit” in the top right corner.
Provide a version name and description for your changes.
Click “Publish”.
Step 5: Test Your Setup
Go to the “Preview” mode in GTM to test your setup.
Navigate to your website and perform a form submission.
Check the GTM Debug Console to see if your form submission is being tracked correctly.
Verify that the event data is being sent to Google Analytics by checking the Real-Time reports in GA.
Additional Tips
Custom Form Submissions: If your form uses AJAX or doesn’t trigger a normal form submission event, you might need to set up custom events or use a JavaScript listener to capture the form submission.
Use the Data Layer: For more complex scenarios, push the form submission data to the data layer and create triggers and tags based on that data.
By following these steps, you should be able to track form submissions effectively using Google Tag Manager.