Troubleshooting view_item Event Issues in GTM4WP for WooCommerce
Content
Many users of the 'GTM4WP – A Google Tag Manager (GTM) plugin for WordPress' encounter issues with the view_item event, a critical component for tracking product views and dynamic remarketing in Google Ads. This guide covers the most common problems and their solutions, based on community reports.
Common view_item Event Problems
The issues typically fall into a few specific categories:
- The
view_itemevent does not fire at all on product pages. - It only fires after a user clicks on a product variant, not when landing directly on a variant URL.
- It fires multiple times for a single pageview, sometimes including data from related products.
- It fires but is missing critical data like the
valuefield.
Why These Issues Happen
1. Variable Product Behavior
The most frequently reported cause is related to variable products (e.g., t-shirts with different colors or sizes). The 'GTM4WP – A Google Tag Manager (GTM) plugin for WordPress' team has designed the plugin so that the view_item event for a variable product is intentionally fired only after a specific variation is selected by the user. This means if a visitor lands directly on a URL with a pre-selected variant (e.g., product/awesome-tshirt/?attribute_color=Blue), the event may not trigger unless they interact with the page.
2. Caching Conflicts
Caching plugins, like LiteSpeed Cache, can serve static HTML pages where the GTM4WP JavaScript has not yet executed. This can prevent the view_item event and other dataLayer pushes from firing on the initial page load.
3. Uncleared DataLayer
In some cases, the ecommerce object in the dataLayer is not cleared between events. This can cause a view_item event to contain leftover product data from a previous view_item_list event, corrupting your data. This is particularly problematic for Google Ads tracking, which uses all available data in the dataLayer.
4. Theme and Page Builder Conflicts
Themes or page builders like Elementor that heavily modify standard WooCommerce templates can sometimes break the JavaScript hooks the plugin uses to detect product views and impressions.
Most Common Solutions
Solution 1: Check for a Plugin Update
First, always ensure you are running the latest version of the plugin. The 'GTM4WP – A Google Tag Manager (GTM) plugin for WordPress' team continuously addresses bugs. For example, a missing value field in the view_item event was a known bug that has been fixed in a development version.
Solution 2: Configure Your Caching Plugin
If events are inconsistent, configure your caching plugin to exclude the GTM4WP scripts from being cached. You may need to set rules to not cache specific cookies, user agents, or URLs. Contact your caching plugin's support for specific instructions on how to make it compatible with GTM4WP.
Solution 3: Manual Trigger for Variable Products
For the variable product issue, a workaround involves manually pushing a view_item event to the dataLayer if a variant is pre-selected on page load. This requires custom JavaScript. You would need to check the URL parameters or the selected variant on page load and then use the dataLayer.push() method to fire the event with the correct product data (using the item_group_id for variable products).
Solution 4: Check Theme Compatibility
If view_item_list is firing instead of view_item, or events are not firing on pages built with Elementor, your theme may not be fully compatible. The 'GTM4WP – A Google Tag Manager (GTM) plugin for WordPress' team provides a guide for developers on how to make a WordPress theme compatible with enhanced ecommerce tracking. Share this resource with your theme developer.
Conclusion
Issues with the view_item event are often rooted in the plugin's designed behavior for variable products, caching, or theme conflicts. By systematically checking for updates, configuring caching, and potentially adding custom code, you can resolve most of these tracking problems and ensure your Google Ads remarketing functions correctly.
Related Support Threads Support
-
Need view_item to fire on variant pageloadhttps://wordpress.org/support/topic/need-view_item-to-fire-on-variant-pageload/
-
‘value’ field missing in some event pusheshttps://wordpress.org/support/topic/value-field-missing-in-some-event-pushes/
-
view_item_list fires on almost all pageshttps://wordpress.org/support/topic/view_item_list-fires-on-all-pages/
-
View Content Event not firing uphttps://wordpress.org/support/topic/view-content-event-not-firing-up/
-
Dynamic Retargeting view_item_list fires in wrong pagehttps://wordpress.org/support/topic/dynamic-retargeting-view_item_list-fires-in-wrong-page/
-
view_item eventhttps://wordpress.org/support/topic/view_item-event/
-
view_item_listhttps://wordpress.org/support/topic/view_item_list-2/
-
I don’t have “message” every timehttps://wordpress.org/support/topic/i-dont-have-message-every-time/
-
view_item fires on the page different timeshttps://wordpress.org/support/topic/view_item-fires-on-the-page-different-times/
-
view_item remarketing not firehttps://wordpress.org/support/topic/view_item-remarketing-not-fire/
-
Clear ecommerce objecthttps://wordpress.org/support/topic/clear-ecommerce-object-2/
-
view_item_list not firehttps://wordpress.org/support/topic/view_item_list-not-file/
-
no view_item event pushedhttps://wordpress.org/support/topic/no-view_item-event-pushed/
-
view_item event doesn’t firehttps://wordpress.org/support/topic/view_item-event-doesnt-fire/
-
“view_item_list” not firing with Elementorhttps://wordpress.org/support/topic/view_item_list-not-firing-with-elementor/
-
view_item_list event + parameters only oncehttps://wordpress.org/support/topic/view_item_list-event-parameters-only-once/
-
view item list fires on homepagehttps://wordpress.org/support/topic/view-item-list-fires-on-homepage/
-
Clear ecommerce objecthttps://wordpress.org/support/topic/clear-ecommerce-object/
-
View Item trigger does not appearhttps://wordpress.org/support/topic/view-item-trigger-does-not-appear/