Commit b23bd6573b for woocommerce
commit b23bd6573b30f015c02769eb168d58f3d8759ae7
Author: Rostislav Wolný <1082140+costasovo@users.noreply.github.com>
Date: Wed Sep 17 08:00:24 2025 +0200
Fix begin_checkout event not tracked id Google Analytics for WooCommerce (#60871)
* Ensure that the render checkout event is not triggered too early
This fixes the issue that the event is not processed by
Google Analytics for WooCommerce
STORMA-60
diff --git a/plugins/woocommerce/changelog/storma-60-begin-checkout-event-is-not-tracked-on-checkout b/plugins/woocommerce/changelog/storma-60-begin-checkout-event-is-not-tracked-on-checkout
new file mode 100644
index 0000000000..4c8e8eb96c
--- /dev/null
+++ b/plugins/woocommerce/changelog/storma-60-begin-checkout-event-is-not-tracked-on-checkout
@@ -0,0 +1,4 @@
+Significance: patch
+Type: fix
+
+Fix render-checkout-form event was possibly triggered too early for 3rd party scripts to catch
diff --git a/plugins/woocommerce/client/blocks/assets/js/blocks/checkout/inner-blocks/checkout-fields-block/frontend.tsx b/plugins/woocommerce/client/blocks/assets/js/blocks/checkout/inner-blocks/checkout-fields-block/frontend.tsx
index 052b98ca5a..843664fec3 100644
--- a/plugins/woocommerce/client/blocks/assets/js/blocks/checkout/inner-blocks/checkout-fields-block/frontend.tsx
+++ b/plugins/woocommerce/client/blocks/assets/js/blocks/checkout/inner-blocks/checkout-fields-block/frontend.tsx
@@ -4,6 +4,7 @@
import type { ReactElement } from 'react';
import clsx from 'clsx';
import { __ } from '@wordpress/i18n';
+import domReady from '@wordpress/dom-ready';
import { Main } from '@woocommerce/base-components/sidebar-layout';
import { useStoreEvents } from '@woocommerce/base-context/hooks';
import { useEffect } from '@wordpress/element';
@@ -21,7 +22,9 @@ const FrontendBlock = ( {
// Ignore changes to dispatchCheckoutEvent callback so this is ran on first mount only.
useEffect( () => {
- dispatchCheckoutEvent( 'render-checkout-form' );
+ domReady( () => {
+ dispatchCheckoutEvent( 'render-checkout-form' );
+ } );
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [] );