Open jorgemd24 opened 3 months ago
Just for when we address this issue. Important to check in all the scenarios and add the test steps in https://github.com/woocommerce/woocommerce-google-analytics-integration/wiki/General-Testing or add E2E
7952298-zen
I tested this issue again, but the results were not clear. In some cases, the redirection happens too quickly, not allowing enough time to send the event however today I got the correct event (add_to_cart) 95% of the time, making it difficult to test.
We could use the woocommerce_add_to_cart_redirect
filter, but this might duplicate the add_to_cart
event if the event is sent correctly on the shop page.
Another alternative is to use transport_type: 'beacon'
as mentioned in this doc, which could help prevent the issue. For now, we'll need to wait and see if this issue affects more merchants.
@jorgemd24 Any news about this one? We have a merchant who is really upset in ticket 7952298-zen
Hi @fetenlakhal, my results weren't clear enough to propose a solution. I'll tag @tomalec, who is the porter this week, to have a second look at this. Thanks for bringing it up.
I was able to reproduce it 100% times with classic [products]
shortcode and Storefront theme. In such case WooCommerce core simply redirect and abort firing the event at all
Another alternative is to use transport_type: 'beacon' as mentioned in this doc, which could help prevent the issue. For now, we'll need to wait and see if this issue affects more merchants.
The docs are no longer there, and from what I found on StackOverflow, the latest analytics use the beacon
by default. And given the WC Core behavior described above, I doubt it would help.
I don't see an easy and 100% reliable solution here :/
I think we could either:
adding_to_cart
event, then check for wc_add_to_cart_params.cart_redirect_after_add
is set, if so assume the product will be eventually added - not 100% reliable, as it may actually fail to add the product.adding_to_cart
was fired - not reliable, as the API is experimental and not supported in Firefox.added_to_cart
event from the cart page after the redirect - not easy, if possible. The only trace I found was in wc_add_to_cart_message
but using its hooks to get what we need feels like a really unstable workaroundadded_to_cart_about_to_redirect
) just before redirecting https://github.com/woocommerce/woocommerce/blob/trunk/plugins/woocommerce/includes/wc-cart-functions.php#L98:L98 - not fast to ship.I think the 4. would be the cleanest and most reliable. However, It could take months to release and upgrade our merchants. I imagine someone from WC Core Team could oppose having a blocking event before such a redirect.
//cc @martynmjones
@tomalec thank you for explaining the issue and offering solutions.
Could you please help with the implementation of the # 4 solution that you proposed? Does it involve modifying the core files? Either way I wouldn't mind doing that I as need a solution for this I am not able to track the add_to_cart event on google ads and really need a solution.
Describe the bug:
The cart event is not sent when "Redirect to the cart page after successful addition" option is enabled.
Steps to reproduce:
Add to Cart
event is not sent.Expected behavior:
Add to Cart event should be sent regardless "Redirect to the cart page after successful addition" option
Actual behavior:
Add to Cart event is not sent when "Redirect to the cart page after successful addition" is enabled.
Additional details: