Tracking form submissions with Google Tag Manager (GTM) is a great way to understand user interactions and measure conversions. Here’s a detailed guide on how to set this up:
1. Set Up Google Tag Manager
- If you don’t have a GTM account, go to the Google Tag Manager website and create an account.
- Follow the instructions provided by GTM to add the container snippet to your website’s HTML, right after the opening
<head>
tag and immediately after the opening<body>
tag.
2. Enable Built-in Variables
- Access GTM:
- Log in to your GTM account and open your container.
- Enable Form Variables:
- Click on “Variables” in the left-hand menu.
- Under “Built-In Variables,” click on “Configure.”
- Enable variables related to forms, such as “Form ID,” “Form Classes,” “Form Element,” “Form Target,” and “Form URL.”
3. Create a Trigger for Form Submissions
- Create a New Trigger:
- Click on “Triggers” in the left-hand menu and then “New.”
- Name the trigger (e.g., “Form Submission Trigger”).
- Configure the Trigger:
- Click on “Trigger Configuration.”
- Select “Form Submission” as the trigger type.
- Refine the Trigger (Optional):
- By default, the trigger will fire on all form submissions. If you want to track specific forms, you can refine the trigger using filters like Form ID or Form Classes.
- Click on “Some Forms” and add conditions to target specific forms (e.g., “Form ID” equals
contact-form
).
- Save the Trigger:
- Click “Save” to create the trigger.
4. Create a Tag for Form Submissions
- Create a New Tag:
- Click on “Tags” in the left-hand menu and then “New.”
- Name the tag (e.g., “Form Submission Tag”).
- Configure the Tag:
- Click on “Tag Configuration.”
- Select the tag type based on your tracking tool. For Google Analytics 4 (GA4), select “Google Analytics: GA4 Event.”
- For Universal Analytics (GA3), select “Google Analytics: Universal Analytics” and choose “Event” as the track type.
- Set Up the Tag:
- For GA4:
- Enter your Measurement ID.
- Set Event Name to something like
form_submission
. - Add any parameters you want to track, such as
form_id
,form_classes
, etc.
- For Universal Analytics (GA3):
- Enter your Tracking ID.
- Fill in the Event Category (e.g.,
Form
), Action (e.g.,Submit
), and optionally Label (e.g.,{{Form ID}}
).
- For GA4:
- Attach the Trigger:
- Click on “Triggering” and select the form submission trigger you created earlier.
- Save the Tag:
- Click “Save” to create the tag.
5. Test the Setup
- Click on “Preview” in the GTM interface to enter debug mode.
- Open your website in a new tab where the GTM debug panel will appear.
- Fill out and submit the form you’re tracking.
- Check the debug panel to ensure that the form submission tag fires correctly upon submission.
6. Publish Your Container
-
- If everything works correctly, return to the GTM interface and click “Submit” to publish your changes.
- Add a version name and description (e.g., “Form submission tracking setup”) and click “Publish.”
7. Verify Data in Google Analytics
-
- Open your Google Analytics account and navigate to the “Real-time” reports.
- Perform a test form submission and verify that the event appears in Google Analytics.
By following these steps, you can set up and track form submissions on your website using Google Tag Manager, helping you gather valuable insights on user interactions and measure conversion rates effectively.