Wed, September 25, 2019
The original article was written on September 29, 2019, and it focused on sending data to Google Analytics Universal. However, during the migration of the blog to a new CMS, I decided to update the content to reflect the current version — Google Analytics 4.
The importance of tracking form submissions on a website can’t be overstated — it’s one of the main ways users can leave a request. I’ve previously written articles on how to track form submissions in Google Tag Manager using a basic trigger or through validation inside the tag manager. Today, I want to show you another method — it’s suitable for forms where a thank-you popup appears after a successful submission. For example, something like this:
This method is based on using the Element Visibility trigger type. So, on the one hand, this article is about form tracking, and on the other — about working with the Element Visibility trigger.
The Element Visibility trigger type helps detect when an element enters the visible area of the screen. Let’s look at its parameters in more detail:
To ensure you’re copying the correct selector that covers all the needed elements, you can use my custom PROANALYTICS extension. This tool highlights elements on the page that match the specified CSS selector.
2. Element ID / Element Selector – Based on the Selection Method value, specify either the element's ID or its CSS selector.
3. When to fire this trigger – This defines how many times the trigger can fire on a page
4. Minimum Percent Visible – Defines the minimum visible percentage of the element required for the trigger to fire. Acceptable values range from 1 to 100. This is useful, for instance, when you want the user to fully see a banner.
5. Set minimum on-screen duration – Defines the minimum time (in milliseconds) the element must remain visible for the trigger to fire.
IMPORTANT! The visibility time is cumulative. If you set 5000 ms (5 seconds) and the user sees the element for 3 seconds, and later again for 2 seconds — the trigger will still fire.
6. Observe DOM changes – Enable this option if the element appears later due to DOM changes. For example, a popup after a form submission.
7. This trigger fires on – Choose Some Visibility Elements to specify additional conditions for firing. For example, only on the homepage, as shown in the screenshot.
Theory is good, but let’s move to practice. In my case, I’ll use a CSS selector because the element doesn’t have an ID. To get it, we first need to fill in the form and see the popup. Then right-click the thank-you element and choose Inspect:
Locate the correct element in the code. Be careful — quite often, the form popup and the thank-you window share the same selector. In that case, the trigger may fire upon form display, which would lead to incorrect data. It’s best to use an element that appears only after a successful form submission — like the thank-you text.
Go to Google Tag Manager and create a new Element Visibility trigger with the following settings:
To send the data to Google Analytics 4, use a standard event-type tag with the following configuration:
Don’t forget to set the Event Name field to the name that matches your setup.
The Element Visibility trigger isn’t just useful for tracking popups — you can use it for other purposes too. For example, measuring the performance of promo banners. Share your ideas in the comments about other ways to use this trigger, and feel free to ask questions if you have any.
If you enjoyed this content, subscribe to my LinkedIn page.
I also run a LinkedIn newsletter with fresh analytics updates every two weeks — here’s the link to join.
Web Analyst, Marketer