• Resolved tmnewslang

    (@tmnewslang)


    Hi,

    We’ve been using your plugin for a while and recently we wanted to start tracking add_to_cart events. All the other events are working (view_item, view_item_list, begin_checkout, purchase and remove_from_cart) but add_to_cart don’t seem to be fired.

    When checking via the developer tools, I can see calls getting sent to GA for all these events, but I never see the add_to_cart. Maybe this is because upon adding to cart, the website automatically redirects to the checkout page?

    Here’s the code I use for this :

    add_filter('woocommerce_add_to_cart_redirect', 'add_to_cart_redirect');

    function add_to_cart_redirect() {
    global $woocommerce;
    return wc_get_checkout_url();
    }

    And after checking the source code of your plugin, it seems the add_to_cart event is fired when the ‘woocommerce_add_to_cart’ WP action is getting triggered (source : class-wc-google-gtag-js.php, line 33).

    Maybe this is not getting triggered with this specific situation?

    Thanks for your help !

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Zubair Zahid (woo-hc)

    (@doublezed2)

    Hello tmnewslang,

    Thank you for contacting Woo support.

    You are correct in your assessment.
    The add_to_cart event isn’t being fired because your custom code is redirecting users directly to the checkout page, bypassing the cart page where this event would typically trigger.

    Since this involves custom code, it’s outside the scope of our standard support.
    However, you might find the assistance you need by reaching out to the Woo Community Facebook group and Woo Community Slack. These are great places to get insights and potential solutions from other developers who may have encountered similar situations.

    I hope this helps.
    Let me know if you have any other questions.

    Best regards.

    Thread Starter tmnewslang

    (@tmnewslang)

    Hello @doublezed2,

    Thanks for the reply and for the confirmation that this is indeed the problem. I’ll dig into it then!

    Plugin Support Zubair Zahid (woo-hc)

    (@doublezed2)

    Hello tmnewslang,

    Thank you for your reply.

    I am happy to be of your help.
    Please don’t hesitate to contact us again if you have more questions or concerns.
    Have a great day!

    Best regards.

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.