Why GTM Element Visibility fires on hidden accordions
GTM Element Visibility firing on hidden accordions or modals? Why display none and opacity zero behave differently, and how to fix the trigger.
An Element Visibility trigger fires on a closed modal because the website's CSS hides the element using opacity: 0 rather than display: none. While the human user sees an empty screen, the browser's rendering engine still calculates the invisible element's height, width, and position in the layout. Google Tag Manager observes that invisible bounding box entering the viewport and immediately fires the tag.
We see this frequently when a marketing team sets up tracking for a pop-up form, a delayed promotional banner, or an expanding FAQ accordion. They configure the trigger correctly in the interface, check the preview mode, and assume everything works. Weeks later, the analytics report claims that 10,000 visitors viewed the pop-up, even though the total website traffic was only 4,000.
How GTM defines visibility
Google Tag Manager relies on a browser technology called the Intersection Observer API. It checks whether a specific element intersects with the visible part of the user's screen. It does not check if the element is visually painted with contrasting colours. It only checks if the mathematical box assigned to that element is positioned inside the viewport.
If a developer hides a modal using display: none, the browser removes the element from the document layout entirely. It takes up zero space. Because it has no dimensions, it cannot intersect with the viewport, and the GTM trigger remains quiet.
If the developer hides the modal using opacity: 0 or visibility: hidden, the element still occupies its full physical space on the page. It is simply transparent. As soon as the user scrolls down to the section of the page where the transparent modal is secretly resting, the Intersection Observer registers a hit. The tag fires, recording a view for a promotion the customer never actually saw.
The cost of tracking invisible elements
When your analytics platform records interactions that never happened, it breaks the conversion funnels you rely on to make commercial decisions.
Consider an expanding "Request a Quote" accordion that rests at the bottom of a B2B product page. The marketing team wants to know how many people open the accordion, so they set an Element Visibility trigger on the form inside it. The form is hidden by default using opacity: 0 for a smooth fade-in animation.
| Visitor Action | Browser State | GTM Trigger Result | Reported Funnel Action |
|---|---|---|---|
| Scrolls past product details | Accordion is closed. Form is opacity: 0 but in the viewport. | Trigger fires immediately. | Quote Form Viewed |
| Clicks to open accordion | Form transitions to opacity: 1. | Trigger ignores it (already fired). | None |
| Leaves the page | Form remains open. | No action. | Abandoned Quote |
In this scenario, every single visitor who scrolls to the bottom of the page is recorded as having viewed the quote form.
| Reporting Metric | Actual Human Interaction | Analytics Dashboard Output | The Gap |
|---|---|---|---|
| Total Page Views | 5,000 | 5,000 | 0 |
| Intentional Accordion Opens | 120 | 4,200 | 4,080 false positives |
| Forms Submitted | 30 | 30 | 0 |
| Form Conversion Rate | 25.0% | 0.7% | 24.3% artificial drop |
If you look at the dashboard, a 0.7% conversion rate suggests the quote form is fundamentally broken or asking too many questions. You might decide to redesign the form, change the pricing strategy, or fire the agency responsible for the landing page. In reality, the form converts exceptionally well at 25%. The only thing broken is the CSS rule hiding the element.
Diagnosing and fixing the CSS conflict
If you are auditing your Google Tag Manager setup and suspect an Element Visibility trigger is firing too early, the fix requires aligning the trigger configuration with the site's rendering behaviour.
We check the developer console to inspect the hidden element. If the CSS rules show display: none, the element is safely removed from the layout. In this case, we simply tick the "Observe DOM changes" box inside the GTM trigger settings. This tells GTM to wait and watch for the moment the developer's script changes the rule to display: block.
If the CSS rules show opacity: 0, the element is transparent but active. In these situations, the Element Visibility trigger is the wrong tool for the job. We cannot rely on viewport intersection. Instead, we check the website's JavaScript to see if we can push a custom event into the data layer exactly when the opacity transition completes. This moves the tracking logic away from fragile CSS styling and ties it directly to the functional code that controls the user interface.
The aim is straightforward. When your dashboard says a customer viewed the promotion, they should have actually seen it.
Frequently asked questions
Why do developers use opacity instead of display none?
Developers often use opacity: 0 or visibility: hidden because it allows for smooth CSS transitions and animations. When an element is set to display: none, it is completely removed from the document flow, making it impossible to animate a gradual fade-in effect when it is reintroduced.
Does ticking 'Observe DOM changes' fix the opacity problem?
No. The "Observe DOM changes" setting in GTM uses a MutationObserver to detect when an element is added to or removed from the DOM structure. If an element is already in the DOM with opacity: 0, it is technically already present and intersecting with the viewport. Changing the opacity to 1 is a style change, not a structural DOM insertion, so the trigger will have already fired prematurely.
Can I just use a click trigger instead?
If the modal or accordion opens as the direct result of a button click, a Click trigger is a much safer alternative. You can track the exact click on the "Open FAQ" button rather than trying to measure the visibility of the resulting text box. This removes the CSS dependency entirely.
What if the modal opens automatically on a timer?
If a pop-up appears on a timer without a user click, you cannot use a Click trigger. If it uses an opacity fade-in, you cannot use an Element Visibility trigger. In this case, you must ask the developer to fire a dataLayer.push({'event': 'modal_shown'}) precisely when the timer executes and the animation finishes.
Will setting a minimum visibility percentage help?
GTM allows you to specify that an element must be a certain percentage visible (e.g., 50%) before the trigger fires. However, this refers to the percentage of the element's mathematical area that has entered the screen boundaries, not its visual opacity. A transparent element that is 100% inside the viewport meets the condition immediately, regardless of this setting.