Insight - Trupharm - Deferred Add To Cart
Briefly delays the single-product add-to-cart submit so tracking pixels queued by the click (GA4 / Meta) reach the network before the page navigates. Keeps the native WooCommerce POST and redirect-to-cart behaviour.
by Insight Marketing · github.com/udiinsight/insight-trupharm-ajax-cart · website
Install
No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:
wp plugin install https://github.com/udiinsight/insight-trupharm-ajax-cart/archive/refs/heads/main.zipDelays the single-product add-to-cart submit so tracking pixels reach the network before the page navigates.
Description
On sugar360.co.il the add-to-cart button submits form.cart natively, and measurement showed the browser begins navigating only ~106ms after the click. Meta's pixel sends its events as image/fetch requests, which are cancelled by that navigation. GA4 survives because it uses sendBeacon.
This plugin intercepts the submit on single product pages, waits a short window (default 400ms, filterable via insight_ajax_cart_send_delay), then submits the form normally with HTMLFormElement.prototype.submit(). The WooCommerce POST and redirect-to-cart behaviour are unchanged - only the start of the navigation moves.
Verified live: the tracking window widened from 106ms to ~1400ms, and a Meta custom event fired on submit completed 592ms before navigation began.
Changelog
2.0.0
- Rewrite: defer the native submit instead of doing an AJAX add-to-cart.
- fix: 1.x used the wc-ajax endpoint and then also fell through to a native submit, adding the product twice per click. Replaced with a single native submit path, which cannot double-add.
- Removes the extra full cart-page fetch that 1.0.0 performed via
redirect: 'follow'.
1.1.0
- Switched from posting the product form to the lightweight
wc-ajax=add_to_cartendpoint. Never released - superseded by 2.0.0 after the double-add was found in testing.
1.0.0
- Initial version: AJAX add-to-cart via the product form. Never released.