woocommerce/woocommerce-google-analytics-integration

Consecutive `remove_from_cart` events are not tracked

tomalec opened this issue · 0 comments

Describe the bug:

When removing items from the cart, only the first removal is tracked. All the following are not. Most probably, because the cart is re-rendered by WC, and our plugin binds events only once on the first load.

Steps to reproduce:

  1. Add 3 items to the cart
  2. Go to the cart page
  3. open network pannel watch for google-analytics.com/g/collect with en=remove_from_cart
  4. (optional) open sources dev tab, put a breakpoint on gtag('event', 'remove_from_cart', { line
  5. Remove the first item from the cart
  6. 🟢 Request to collect is sent
  7. Remove another item from the cart
  8. 🔴 No request with en=remove_from_cart is sent

Expected behavior:

en=remove_from_cart should be send for each consecutive removal.

Actual behavior:

No request with en=remove_from_cart is sent for 2+ removed items

Additional details:

This was found during WC 7.9 testing.
But it is probably an older issue and a reason of confusion in testing instruction

After removing an item from the cart, confirm the request to google-analytics.com/g/collect with en=remove_from_cart NOTE Not working as of 2022-04-27 Confirmed working as of 2022-08-29.