![](https://images.ctfassets.net/14a5d7mfz4o7/5RYZxEWqRxa4dKiih9XjKB/53627a7304832eec7542138fe3f052d0/7__2_.png?w=750&h=285&q=50&fm=png)
2020-06-20
The Guide to Form Tracking in Google Tag Manager (GTM)
Part of what makes Google Tag Manager so great is that it provides simple built-in utilities–called “triggers”–that enable you to track user interaction events like page views, clicks, and form submissions without having to write code. It empowers marketers to track user behavior without relying on developers.
But sometimes that accessibility comes at the cost of reliability. If you’ve used the built-in Form Submission trigger in GTM, you might have noticed this. Depending on how forms are implemented on your site, you may find that your built-in form submission triggers either aren’t firing at all or that they’re firing far too often.
In this article, we’re going to walk you through all of the tools available in your tool belt when tracking form submissions using GTM, and lay out the use cases, tradeoffs, and common pitfalls of each:
Tracking thank you page views
Using the built-in form submission trigger
Tracking clicks on the submit button
Using custom DOM event listeners (advanced)
Tracking thank you element visibility
Tracking Thank You Page Views
We put this one first on the list, because it’s the most reliable option. If your form redirects users to a dedicated thank you page upon submission, you should use thank you page views to track submissions.
DESTINATION-BASED GOALS IN GOOGLE ANALYTICS
Technically, you don’t even need to use GTM to track thank you page views. You could just set up a destination-based goal in Google Analytics. For example, you might set up a goal that looks like this:
![Thank-you-page-view-destination-based-goal-google-analytics](http://images.ctfassets.net/14a5d7mfz4o7/5eWzADK9BEdjT4ncxd4PMx/a4cd1629e908f07cb97e087b323d97fd/Thank-you-page-view-destination-based-goal-google-analytics.png)
A destination-based goal that tracks page views of all URLs containing “thank-you”
This will work just fine, and Google Analytics will, by default, only count unique page views. So if a user refreshes the thank you page, it will only register one goal completion.
But we can make this just a little bit better if we use event tracking.
EVENT TRACKING IN GOOGLE TAG MANAGER
Let’s say your site has multiple forms, and your marketing department is always adding new forms for special promotions that all take the user to different thank you pages upon submission. We can use the built-in Page View trigger in GTM to fire an event when the user visits a thank-you page like so:
![Thank-You-Page-Trigger-GTM](http://images.ctfassets.net/14a5d7mfz4o7/2ReV8qv5xxDZkO4np6oXad/33a8df0737d6a4a50b1b857ae8410028/Thank-You-Page-Trigger-GTM.png)
A standard thank you page view trigger in GTM
And then we can set up triggers for other specific thank you pages. For example, if you have a dedicated thank you page for your contact form at “/thank-you-contact”, your trigger might look like this:
![Screen-Shot-2020-09-04-at-2.38.14-PM](http://images.ctfassets.net/14a5d7mfz4o7/2LxO8sDm5I6RXH7Pz4PIDY/42dd555fad553a1292c908d637314263/Screen-Shot-2020-09-04-at-2.38.14-PM.png)
A contact us thank you page view trigger in GTM
Now, with your “All Thank You Page Views” and “Contact Us Thank You Page Views” triggers set up, you can create two Google Analytics Event tags like so:
![Screen-Shot-2020-03-05-at-12.11.03-PM](http://images.ctfassets.net/14a5d7mfz4o7/cMGyO4r7aiLRg4JKYMe6A/1a8f0aaeac85a3038ec6381d38e1836f/Screen-Shot-2020-03-05-at-12.11.03-PM.png)
How to implement a catchall “Other Form Submission” event using Exceptions.
The first event will only fire on the contact us thank you page, and the second will fire on all thank you pages except the contact us one. As long as your thank you page URLs all contain the string “thank-you”, the second will serve as a catchall to track any forms that either don’t have a dedicated thank you page or don’t need to be tracked with a event or goal in Google Analytics.
Note: You can apply this “catchall” strategy using exceptions to any of the form tracking approaches in this guide. We just included it in the thank you page section to show the benefits of using Google Analytics event tracking over destination-based goals.
WHEN THANK YOU PAGE TRACKING WON’T WORK
This one’s pretty simple. If your forms don’t take users to a thank you page, this method won’t work.
Using the Built-in Form Submission Trigger
If your forms don’t send users to thank you pages, the next tool you’ll want to reach for is the built-in form submission trigger.
One of the great things about the built-in triggers in GTM is that they’re super easy to set up. You can give them a try and quickly learn whether they’ll work for your use case or not.
To find out whether the built-in trigger will work for you, set up a trigger that listens for all form submissions, hook it up to any tag, enter preview mode, submit a form on your site, and see if it fires:
![Screen-Shot-2020-09-04-at-2.32.53-PM](http://images.ctfassets.net/14a5d7mfz4o7/6t1RlUSFhTPqBOwDq9pFbt/cdee98d00bcab04188d92dda7f8aeec2/Screen-Shot-2020-09-04-at-2.32.53-PM.png)
Trigger that fires on all form submissions. You can specify a “wait for tags” time if you’d like, but we find that it typically doesn’t make much of a difference if you’re just firing one Google Analytics event.
![Screen-Shot-2020-09-04-at-2.34.39-PM](http://images.ctfassets.net/14a5d7mfz4o7/5R2ThWFtuxVjdXnv394WUe/e9a0a0d794a82a04831ef9957f42fb60/Screen-Shot-2020-09-04-at-2.34.39-PM.png)
A tag that’s hooked up to our new trigger
![Screen-Shot-2020-09-04-at-2.42.14-PM](http://images.ctfassets.net/14a5d7mfz4o7/1LF1r9soXl7GStItKrLAHQ/d23abd4f65e8ff8df170b4ff12be0cea/Screen-Shot-2020-09-04-at-2.42.14-PM.png)
Preview mode in GTM
If you don’t see the Form Submit data layer event come through, then the built-in trigger probably won’t work for you, and you should try one of the other approaches. If you did see the Form Submit data layer event come through, then you can proceed to testing in production.
Depending on the number of submissions you see on a daily basis, it may take several days to accumulate enough data for you to determine whether or not the trigger’s fire rate is within an acceptable margin of error. We usually compare actual vs. reported form submissions on a daily basis when running a test like this.
If after a few days, you’re seeing that the trigger is over- or under-firing, move on to the next tracking method.
WHEN THE BUILT-IN FORM SUBMISSION TRIGGER WON’T WORK
This one is more complicated. In short, it depends on how forms are implemented on your site.
There are many ways that forms are implemented on the web. Sometimes developers disable the default form submit behavior when they need a form to take a custom action after it’s submitted. When this is the case, GTM’s event listener has no way of knowing that a form submission occurred.
Note: For those interested in a technical explanation on why the built-in form submission trigger doesn’t always work, check out Simo Ahava’s post on the subject.
Tracking Clicks on the Submit Button
If the built-in trigger is not working for you and your form doesn’t take the user to a thank you page, “click to submit” tracking may be your next best option.
The simplest way to configure this is to use the the built-in “Click – All Elements” trigger set to “Some Clicks” where you either specify the unique CSS class or id of your submit button:
![Screen-Shot-2020-03-05-at-3.46.22-PM](http://images.ctfassets.net/14a5d7mfz4o7/5aIjWbh50HdUyzgxyboR7m/3f6efd4087b0a80cfe1d3461e4d55c68/Screen-Shot-2020-03-05-at-3.46.22-PM.png)
Click to submit trigger where the button’s unique CSS class is “submit btn_primary”
We’d recommend testing this approach in the same way you would test the built-in form submission trigger–first, confirm that the data layer events are coming through in preview mode, then test for a few days in production–monitoring closely–until you have enough data to tell whether it’s working well enough for you.
Note: If the user presses Enter to submit the form, the “click” trigger will usually still fire.
WHEN TRACKING CLICKS ON THE SUBMIT BUTTON WON’T WORK
Sometimes the submit button’s inner text is wrapped in another HTML tag–most often a <span> tag. When that’s the case, your submit button click triggers will under-fire. This happens because clicks on the button text will register as clicks on the <span> element instead of clicks on the encapsulating <button> or <input> element.
Depending on the number of fields in your form and how strict its data validation settings are, submit button click tracking may over-count form submissions. It would over-count if a number of users click to submit your form, the data validation fails, and they bounce. If the data validation fails and the user proceeds to successfully submit the form, the event will still double-fire, but Google Analytics will only count one goal completion (assuming you have created an event-based goal).
Using Custom DOM Event Listeners (Advanced)
If none of the above approaches work for you, you may need to put on your pocket protector and hit Chrome DevTools.
The first step to setting up custom DOM event listeners is to check and see what DOM events are being fired on your form submissions. To see this, type the following code into the console and check the box next to “Preserve Log”:
monitorEvents(document.body);
Now, when you mouse over your site, you will see a stream of events appear in your console:
![Screen-Shot-2020-03-05-at-4.49.32-PM](http://images.ctfassets.net/14a5d7mfz4o7/238NgKdJtovPj8LFvVFCu1/7f78f83fd8244d3c832c509b99622c83/Screen-Shot-2020-03-05-at-4.49.32-PM.png)
The output of monitorEvents(document.body)
Next, submit the form you want to track and see what DOM event is printed to the console. If you see an event like this, then this approach should work for you:
![Screen-Shot-2020-03-05-at-4.54.22-PM](http://images.ctfassets.net/14a5d7mfz4o7/3dfa7AqANs3bITpVd51u0x/022aec5f4b5940f9826e118554581eb7/Screen-Shot-2020-03-05-at-4.54.22-PM.png)
The output of monitorEvents(document.body) when a form submission event occurs
The next step is to set up a custom data layer event to fire when that DOM event occurs.
![Screen-Shot-2020-03-05-at-5.05.58-PM](http://images.ctfassets.net/14a5d7mfz4o7/5UNW4MTSB2O6Xk301fEamn/3f606ece16103fed74eb8cfa57096c7f/Screen-Shot-2020-03-05-at-5.05.58-PM.png)
Custom data layer event
We then set a trigger to listen for that custom data layer event:
![Screen-Shot-2020-03-05-at-5.07.37-PM](http://images.ctfassets.net/14a5d7mfz4o7/6oUOgiPGcVpX9wkAir83y7/e22b0a5ba48e9e6b1af046bf658da0a3/Screen-Shot-2020-03-05-at-5.07.37-PM.png)
Trigger that listens for our custom data layer event
And that’s it! You can now use that custom event trigger to trigger your Google Analytics events.
Tracking Thank You Element Visibility
The use case for this method is rare in our experience, but we included it on our list, because we have had to use it before, so we figured you might need it one day too.
If your form submits without reloading the page and shows a thank you message, this method may work for you. Here is what an element visibility trigger looks like:
![Screen-Shot-2020-03-05-at-4.27.00-PM](http://images.ctfassets.net/14a5d7mfz4o7/2cW8z8uqfn220MFDaQuLs3/7e930ef3fda69ad8e94bb220d82fb0ea/Screen-Shot-2020-03-05-at-4.27.00-PM.png)
Element visibility trigger that listens for DOM changes
A few things to note about this trigger:
We’re using a CSS selector to identify the element that’s visibility we’re interested in tracking.
We’ve set the percentage visible to 1%, because we don’t care how much of the element is visible. If it’s on the page, fire the event.
We’ve set the trigger to observe DOM changes. You don’t need to enable this if your thank you message is always on the DOM and changes from “hidden” to “visible” on form submit.
Anything We Missed?
Have you tried all of these methods and your form submission tracking still isn’t working? Let us know!
![](https://images.ctfassets.net/14a5d7mfz4o7/6s5B3K1bcfOlPUSQyms2HP/b96988eccc80218d69f372b4219f75e6/Adam_Gnuse.jpg?w=512&h=512&fl=progressive&q=50&fm=jpg)
Adam Gnuse
SEO Analyst, Saltbox Solutions
Adam Gnuse is an SEO Analyst with Saltbox Solutions who works with clients in tech, e-commerce, and healthcare. A London Times bestselling author, Adam’s writing can be found in the Guardian, Daily Telegraph, Lit Hub, and other venues.