Closed GeekPress closed 3 years ago
Reproduced the issue on local installation with GTM4WP + WooCommerce
The issue happens because the inline script is delayed, but the external script for WooCommerce tracking is not with the default exclusion list.
The external script is executed immediately, but can't find the inline variable it depends on, and throws the error.
var gtm4wp
from delay JS in the exclusion array in Engine/Optimization/DelayJS/HTML::$excluded
DelayJS/HTML::delay_js
and DelayJS/Subscriber::delay_js
Effort [XS]
Note: For retest, In google tag manager -> integration -> woocommerce => enable Track enhanced e-commerce
Before submitting an issue please check that you’ve completed the following steps:
Describe the bug Google Tag Manager for WordPress plugin is adding its JS variables without the usage of wp_enqueuescript. We might want to exclude the following pattern: var gtm4wp
To Reproduce Steps to reproduce the behavior:
Expected behavior Variable definitions should not be delayed.
Additional context
Google Tag Manager for WordPress is installed on 500,000+ active websites.
The whole script:
Related ticket: https://secure.helpscout.net/conversation/1547254446/272681?folderId=273768
Backlog Grooming (for WP Media dev team use only)