dsilva90
Forum Replies Created
-
I found my own way to fix this for shopkeeper theme.
In /wp-content/plugins/duracelltomi-google-tag-manager/integration/woocommerce.php file, search for the function gtm4wp_woocommerce_enhanced_ecom_product_click()
Here I add “a:not(.getbowtied_product_quick_view_button)” to the selector to exclude the quick view from redirecting to the product page, like this:
$( '.products li:not(.product-category) a:not(.getbowtied_product_quick_view_button) a:not(.add_to_cart_button),.widget-product-item' ).click(function( event )I know this is specific for shopkeeper getbowtied product quick view plugin but I think it can help finding the problem.
So the problem is that this plugin is not taking in count that inside
ul .productscan be present a quick view link, and in those cases we don’t want to redirect to the product page.Or maybe my solution is not the ideal and we should catch the click event here in this cases for analytics purposes but in eventCallback in case of quick_view we return nothing before the redirect.
What’s your opinion Thomas?
Best regards and thanks for the this awsome plugin.
Keep the good work,Diogo Silva
- This reply was modified 9 years, 2 months ago by Steven Stern (sterndata).
- This reply was modified 9 years, 2 months ago by dsilva90.
- This reply was modified 9 years, 2 months ago by dsilva90.
- This reply was modified 9 years, 2 months ago by dsilva90. Reason: just styling
- This reply was modified 9 years, 2 months ago by dsilva90. Reason: just styling
Hi Thomas,
We are facing the same redirect to product page problem when we click in the Quick View due to callbackEvent, more precisely this line of code:
document.location.href = productdata.data( 'gtm4wp_product_url' )The function where the redirect occurs in our case is the following:
$('.products li:not(.product-category) a:not(.add_to_cart_button),.widget-product-item').click(function(event) { var _productdata = $(this).closest('.product'); if (_productdata.length > 0) { var productdata = _productdata.find('.gtm4wp_productdata'); } else { var _productdata = $(this).closest('ul.products li'); if (_productdata.length > 0) { var productdata = _productdata.find('.gtm4wp_productdata'); } else { var productdata = jQuery(this); } } if (('undefined' == typeof productdata.data('gtm4wp_product_id')) || ('' == productdata.data('gtm4wp_product_id'))) { return true; } var ctrl_key_pressed = event.ctrlKey; event.preventDefault(); 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 var _productpage = window.open('about:blank', '_blank'); } dataLayer.push({ 'event': 'gtm4wp.productClickEEC', 'ecommerce': { 'currencyCode': 'EUR', 'click': { 'actionField': { 'list': productdata.data('gtm4wp_productlist_name') }, 'products': [{ 'id': productdata.data('gtm4wp_product_id'), 'name': productdata.data('gtm4wp_product_name'), 'price': productdata.data('gtm4wp_product_price'), 'category': productdata.data('gtm4wp_product_cat'), 'position': productdata.data('gtm4wp_product_listposition') }] } }, 'eventCallback': function() { if (ctrl_key_pressed && _productpage) { _productpage.location.href = productdata.data('gtm4wp_product_url'); } else { document.location.href = productdata.data('gtm4wp_product_url') } }, 'eventTimeout': 2000 }); });Best Regards
Diogo Silva