Commit 827d4a4f0d5 for woocommerce

commit 827d4a4f0d520a419c0a653bf36f2cd567cf3131
Author: Jill Q. <jill.quek@automattic.com>
Date:   Tue May 19 10:21:49 2026 +0800

    Floating header: Tracks instrumentation for Screen Options and Help icon clicks (#65131)

    Floating header: add Tracks for gear and ? icon clicks

    Fires wcadmin_header_meta_icon_click with `icon` and `action` (open/close)
    so engagement with the Screen Options and Help icons is measurable.
    The pre-click aria-expanded is read before triggerMetaIcon() because
    wp-admin's screen-meta.js flips it synchronously on call.

    Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>

diff --git a/plugins/woocommerce/changelog/sprinkle-floating-header-meta-icon-tracks b/plugins/woocommerce/changelog/sprinkle-floating-header-meta-icon-tracks
new file mode 100644
index 00000000000..298f9a268d0
--- /dev/null
+++ b/plugins/woocommerce/changelog/sprinkle-floating-header-meta-icon-tracks
@@ -0,0 +1,4 @@
+Significance: patch
+Type: add
+
+Add Tracks instrumentation to the floating header's Screen Options (gear) and Help (?) icon buttons. Fires `wcadmin_header_meta_icon_click` with `icon` and `action` (open/close) so engagement with these two icons can be measured.
diff --git a/plugins/woocommerce/client/admin/client/header/embed.tsx b/plugins/woocommerce/client/admin/client/header/embed.tsx
index e76b74d0208..4cfaac2aed5 100644
--- a/plugins/woocommerce/client/admin/client/header/embed.tsx
+++ b/plugins/woocommerce/client/admin/client/header/embed.tsx
@@ -5,6 +5,7 @@ import clsx from 'clsx';
 import { __ } from '@wordpress/i18n';
 import { Button, Icon } from '@wordpress/components';
 import { cog, help } from '@wordpress/icons';
+import { recordEvent } from '@woocommerce/tracks';

 /**
  * Internal dependencies
@@ -55,12 +56,23 @@ export const EmbedHeader = ( {
 					label={ __( 'Screen options', 'woocommerce' ) }
 					aria-expanded={ activeMetaIcon === 'screen-options' }
 					showTooltip
-					onClick={ () =>
+					onClick={ () => {
+						// Capture the pre-click state so we can tell `open`
+						// from `close` clicks. wp-admin's screen-meta.js flips
+						// aria-expanded synchronously inside triggerMetaIcon(),
+						// so reading it after would lose the original signal.
+						recordEvent( 'header_meta_icon_click', {
+							icon: 'screen-options',
+							action:
+								activeMetaIcon === 'screen-options'
+									? 'close'
+									: 'open',
+						} );
 						triggerMetaIcon(
 							'screen-options',
 							'#show-settings-link'
-						)
-					}
+						);
+					} }
 				>
 					<Icon icon={ cog } size={ 18 } />
 				</Button>
@@ -73,9 +85,14 @@ export const EmbedHeader = ( {
 					label={ __( 'Help', 'woocommerce' ) }
 					aria-expanded={ activeMetaIcon === 'help' }
 					showTooltip
-					onClick={ () =>
-						triggerMetaIcon( 'help', '#contextual-help-link' )
-					}
+					onClick={ () => {
+						recordEvent( 'header_meta_icon_click', {
+							icon: 'help',
+							action:
+								activeMetaIcon === 'help' ? 'close' : 'open',
+						} );
+						triggerMetaIcon( 'help', '#contextual-help-link' );
+					} }
 				>
 					<Icon icon={ help } size={ 18 } />
 				</Button>