Back to Community

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_item event 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 value field.

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