Help with duplicate firing of Google Tag events

This topic has 4 replies, 2 voices, and was last updated 3 weeks, 1 days ago ago by Jack Richardson

  • Avatar: Roobinda
    Roobinda
    Participant
    June 12, 2024 at 20:02

    Hi there. I have Google Tag Manager for WooCommerce PRO installed. I opened a support ticket with them as I have duplicate add_to_cart events firing on both my XStore sites. They tell me it’s due the the ajax_add_to_cart class. What are your thoughts on this?

    Their exact message is as follows:
    Doubled add_to_cart event on product page is caused by incorrect/unnecessary css class pinned to “add to cart” button. This element shouldn’t have “ajax_add_to_cart” according to WooCommerce theme standards. The Add to cart button on the single page should have “single_add_to_cart_button” css class. In your case, the button has both classes, so the event is doubled (triggered twice by JavaScript).

    3 Answers
    Avatar: Jack Richardson
    Jack Richardson
    Support staff
    June 13, 2024 at 07:48

    Dear @Roobinda,

    We have implemented the ‘ajax_add_to_cart’ class to facilitate the AJAX-based addition of products to your cart, utilizing WooCommerce’s functionality. Should you prefer the standard method of adding products to your cart, which includes a page refresh, you may opt to disable the ‘Ajax Add To Cart’ feature. This can be done by navigating to Theme Options -> WooCommerce -> Single Product -> Layout. For your convenience, here is a direct link to the settings: https://prnt.sc/kFLekpq9OLwa.

    Upon deactivation, the ‘Add to Cart’ button on single product pages will no longer include the ‘ajax_add_to_cart’ class; it will solely contain the ‘single_add_to_cart_button’ class. Additionally, if you have established contact with the plugin developers, it may be beneficial for them to implement conditions to handle scenarios where both classes are applied to a button. This would help prevent any potential issues with double triggering.

    Deactivating the ‘Ajax Add To Cart’ as described should resolve your concerns regarding double triggering. Should you require further assistance or have any questions, please do not hesitate to contact us.

    Best Regards,
    Jack Richardson
    The 8Theme Team

    Avatar: Roobinda
    Roobinda
    Participant
    June 13, 2024 at 15:25

    Thank you for the comprehensive answer Jack.
    I have tested this and switching off AJAX add to cart on the single product pages does the trick.
    Is there a way to switch AJAX off on the ‘Add to Cart’ buttons on the shop/archive pages?

    Avatar: Jack Richardson
    Jack Richardson
    Support staff
    June 14, 2024 at 08:08

    Dear @Roobinda,

    We hope this message finds you well. To deactivate the AJAX functionality on product archives, please navigate to the global WooCommerce settings and disable the option titled ‘Enable AJAX add to cart buttons on archives’. For your convenience, here is a screenshot of the settings page: https://prnt.sc/-8KWNDB5BFjs.

    Should you require any further assistance, please do not hesitate to contact us.

    Best Regards,
    Jack Richardson
    The 8Theme Team

  • Viewing 4 results - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.Log in/Sign up

We're using our own and third-party cookies to improve your experience and our website. Keep on browsing to accept our cookie policy.