Our website was implemented in such a way that when you click a product on the products list it should open in a new tab. We've added the target="_blank" to the products links but it still open in the same tab (ignoring the target). When we disable the gtm4wp plugin, it works as expected.
I've debugged the plugin and found following fragments of the js/gtm4wp-woocommerce-enhanced.js file:
if ( ctrl_key_pressed ) {
// we need to open the new tab/page here so that popup blocker of the browser doesn't block our code
window.productpage_window = window.open( 'about:blank', '_blank' );
}
(...)
if ( ctrl_key_pressed && productpage_window ) {
productpage_window.location.href = dom_productdata.getAttribute( 'data-gtm4wp_product_url' );
} else {
document.location.href = dom_productdata.getAttribute( 'data-gtm4wp_product_url' );
}
Would it be possible to expand the ctrl_key_pressed condition to also include a check for target value?
Hi @duracelltomi
Our website was implemented in such a way that when you click a product on the products list it should open in a new tab. We've added the
target="_blank"
to the products links but it still open in the same tab (ignoring thetarget
). When we disable thegtm4wp
plugin, it works as expected.I've debugged the plugin and found following fragments of the
js/gtm4wp-woocommerce-enhanced.js
file:Would it be possible to expand the
ctrl_key_pressed
condition to also include a check fortarget
value?I can prepare a code fix if that will help.