Skip to content

Conversation

@ankitrox
Copy link
Collaborator

@ankitrox ankitrox commented Nov 17, 2025

Summary

Addresses issue:

Relevant technical choices

PR Author Checklist

  • My code is tested and passes existing unit tests.
  • My code has an appropriate set of unit tests which all pass.
  • My code is backward-compatible with WordPress 5.2 and PHP 7.4.
  • My code follows the WordPress coding standards.
  • My code has proper inline documentation.
  • I have added a QA Brief on the issue linked above.
  • I have signed the Contributor License Agreement (see https://cla.developers.google.com/).

Do not alter or remove anything below. The following sections will be managed by moderators only.

Code Reviewer Checklist

  • Run the code.
  • Ensure the acceptance criteria are satisfied.
  • Reassess the implementation with the IB.
  • Ensure no unrelated changes are included.
  • Ensure CI checks pass.
  • Check Storybook where applicable.
  • Ensure there is a QA Brief.
  • Ensure there are no unexpected significant changes to file sizes.

Merge Reviewer Checklist

  • Ensure the PR has the correct target branch.
  • Double-check that the PR is okay to be merged.
  • Ensure the corresponding issue has a ZenHub release assigned.
  • Add a changelog message to the issue.

@ankitrox ankitrox changed the title Add GA event tracking for the Analytics setup screen. [11722] Add GA event tracking for the Analytics setup screen. Nov 17, 2025
@github-actions
Copy link

Storybook is ready:

@github-actions
Copy link

github-actions bot commented Nov 17, 2025

Build files for 5087bf3 have been deleted.

@github-actions
Copy link

github-actions bot commented Nov 17, 2025

Size Change: +132 B (+0.01%)

Total Size: 2.19 MB

ℹ️ View Unchanged
Filename Size Change
./dist/assets/blocks/reader-revenue-manager/block-editor-plugin/editor-styles.css 124 B 0 B
./dist/assets/blocks/reader-revenue-manager/block-editor-plugin/editor-styles.js 20 B 0 B
./dist/assets/blocks/reader-revenue-manager/block-editor-plugin/index.js 42.7 kB 0 B
./dist/assets/blocks/reader-revenue-manager/common/editor-styles.css 307 B 0 B
./dist/assets/blocks/reader-revenue-manager/common/editor-styles.js 20 B 0 B
./dist/assets/blocks/reader-revenue-manager/contribute-with-google/index.js 5.88 kB 0 B
./dist/assets/blocks/reader-revenue-manager/contribute-with-google/non-site-kit-user.js 5.07 kB 0 B
./dist/assets/blocks/reader-revenue-manager/subscribe-with-google/index.js 5.88 kB 0 B
./dist/assets/blocks/reader-revenue-manager/subscribe-with-google/non-site-kit-user.js 5.07 kB 0 B
./dist/assets/blocks/sign-in-with-google/editor-styles.css 84 B 0 B
./dist/assets/blocks/sign-in-with-google/editor-styles.js 20 B 0 B
./dist/assets/blocks/sign-in-with-google/index.js 18.6 kB 0 B
./dist/assets/css/googlesitekit-admin-css-********************.min.css 64.5 kB 0 B
./dist/assets/css/googlesitekit-adminbar-css-********************.min.css 11.7 kB 0 B
./dist/assets/css/googlesitekit-authorize-application-css-********************.min.css 846 B 0 B
./dist/assets/css/googlesitekit-wp-dashboard-css-********************.min.css 8.57 kB 0 B
./dist/assets/js/146-********************.js 963 B 0 B
./dist/assets/js/201-********************.js 2.85 kB 0 B
./dist/assets/js/314-********************.js 100 kB 0 B
./dist/assets/js/315-********************.js 3.08 kB 0 B
./dist/assets/js/379-********************.js 3.7 kB 0 B
./dist/assets/js/590-********************.js 1.89 kB 0 B
./dist/assets/js/640-********************.js 2.36 kB 0 B
./dist/assets/js/909-********************.js 1.01 kB 0 B
./dist/assets/js/analytics-advanced-tracking-********************.js 475 B 0 B
./dist/assets/js/googlesitekit-activation-********************.js 24.1 kB 0 B
./dist/assets/js/googlesitekit-ad-blocking-recovery-********************.js 54.9 kB 0 B
./dist/assets/js/googlesitekit-adminbar-********************.js 34.5 kB 0 B
./dist/assets/js/googlesitekit-api-********************.js 7.79 kB 0 B
./dist/assets/js/googlesitekit-block-tracking-********************.js 5.51 kB 0 B
./dist/assets/js/googlesitekit-components-********************.js 5.74 kB 0 B
./dist/assets/js/googlesitekit-consent-mode-********************.js 25.5 kB 0 B
./dist/assets/js/googlesitekit-data-********************.js 1.7 kB 0 B
./dist/assets/js/googlesitekit-datastore-forms-********************.js 6.99 kB 0 B
./dist/assets/js/googlesitekit-datastore-location-********************.js 1.51 kB 0 B
./dist/assets/js/googlesitekit-datastore-site-********************.js 17.3 kB 0 B
./dist/assets/js/googlesitekit-datastore-ui-********************.js 7.11 kB 0 B
./dist/assets/js/googlesitekit-datastore-user-********************.js 22.8 kB 0 B
./dist/assets/js/googlesitekit-entity-dashboard-********************.js 61.7 kB 0 B
./dist/assets/js/googlesitekit-events-provider-contact-form-7-********************.js 1.77 kB 0 B
./dist/assets/js/googlesitekit-events-provider-easy-digital-downloads-********************.js 745 B 0 B
./dist/assets/js/googlesitekit-events-provider-mailchimp-********************.js 1.77 kB 0 B
./dist/assets/js/googlesitekit-events-provider-ninja-forms-********************.js 1.69 kB 0 B
./dist/assets/js/googlesitekit-events-provider-optin-monster-********************.js 1.72 kB 0 B
./dist/assets/js/googlesitekit-events-provider-popup-maker-********************.js 1.79 kB 0 B
./dist/assets/js/googlesitekit-events-provider-woocommerce-********************.js 1.13 kB 0 B
./dist/assets/js/googlesitekit-events-provider-wpforms-********************.js 1.77 kB 0 B
./dist/assets/js/googlesitekit-i18n-********************.js 6.16 kB 0 B
./dist/assets/js/googlesitekit-key-metrics-setup-********************.js 46.6 kB 0 B
./dist/assets/js/googlesitekit-main-dashboard-********************.js 135 kB +41 B (+0.03%)
./dist/assets/js/googlesitekit-metric-selection-********************.js 52.7 kB 0 B
./dist/assets/js/googlesitekit-modules-********************.js 19.9 kB 0 B
./dist/assets/js/googlesitekit-modules-ads-********************.js 47.6 kB 0 B
./dist/assets/js/googlesitekit-modules-adsense-********************.js 133 kB +34 B (+0.03%)
./dist/assets/js/googlesitekit-modules-analytics-4-********************.js 187 kB +24 B (+0.01%)
./dist/assets/js/googlesitekit-modules-pagespeed-insights-********************.js 23.5 kB 0 B
./dist/assets/js/googlesitekit-modules-reader-revenue-manager-********************.js 43.6 kB 0 B
./dist/assets/js/googlesitekit-modules-search-console-********************.js 65.2 kB 0 B
./dist/assets/js/googlesitekit-modules-sign-in-with-google-********************.js 34.4 kB 0 B
./dist/assets/js/googlesitekit-modules-tagmanager-********************.js 30 kB 0 B
./dist/assets/js/googlesitekit-notifications-********************.js 60.9 kB 0 B
./dist/assets/js/googlesitekit-polyfills-********************.js 230 B 0 B
./dist/assets/js/googlesitekit-settings-********************.js 124 kB 0 B
./dist/assets/js/googlesitekit-splash-********************.js 73.5 kB 0 B
./dist/assets/js/googlesitekit-user-input-********************.js 46 kB 0 B
./dist/assets/js/googlesitekit-vendor-********************.js 322 kB 0 B
./dist/assets/js/googlesitekit-widgets-********************.js 104 kB 0 B
./dist/assets/js/googlesitekit-wp-dashboard-********************.js 60.1 kB +33 B (+0.05%)
./dist/assets/js/runtime-********************.js 1.93 kB 0 B

compressed-size-action

Copy link
Collaborator

@abdelmalekkkkk abdelmalekkkkk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @ankitrox! This looks great. I left a few minor comments/questions. Please let me know your thoughts.

await trackEvent( 'moduleSetup', 'cancel_module_setup', moduleSlug );
}, [ moduleSlug ] );

const isInitialSetupFlow =
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we move this to the top of the component? This works perfectly fine but would sit nicely below the showProgress and the other declarations.

'complete_module_setup',
moduleSlug
);
const completionEventArgs = isInitialSetupFlow
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use a simple if/else here? It would be more readable in my opinion.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestion @abdelmalekkkkk.

I think we should stick to ternary operator here because of following reasons:

  1. This is fairly simple expression.
  2. If we use if...else statement we may have to either call trackEvent twice or need to use let completionEventArgs which is susceptible to change which is a source of potential side-effect bugs.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @ankitrox, thanks for explaining your rationale here, however, I would agree with @abdelmalekkkkk that it would be more readable to use an if/else. It won't result in calling trackEvent() twice, simply writing it twice, which seems fine when considering the improved legibility:

			if ( isInitialSetupFlow ) {
				await trackEvent(
					`${ viewContext }_setup`,
					'setup_flow_v3_complete_analytics_step'
				);
			} else {
				await trackEvent(
					'moduleSetup',
					'complete_module_setup',
					moduleSlug
				);
			}

'proxy'
);

const createAccountEventArgs = isInitialSetupFlow
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My reply above also applies here, please do update this to use an if/else.

hasGTMScope,
setValues,
viewContext,
isInitialSetupFlow,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason why you added isInitialSetupFlow and viewContext to the dependency array here but not in ModuleSetup.js? Doesn't seem like a big deal, but I'm wondering if we can keep things consistent.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good catch @abdelmalekkkkk , thanks for spotting it.

I've added it now.

cleanup();
} );

it( 'should track initial setup flow create account event when showProgress=true', async () => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the label needs to be something along the lines of "during initial setup flow" instead of "when showProgress=true", because showProgress is not the only condition.

expect( genericCreateAccountCall ).toBeUndefined();
} );

it( 'should track generic create account event when showProgress is not true', async () => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

@ankitrox
Copy link
Collaborator Author

Thanks for reviewing the PR @abdelmalekkkkk

I've addressed the necessary changes and responded on couple of comments. Please let me know if you observe any further issues.

Thanks!

@abdelmalekkkkk
Copy link
Collaborator

Thanks @ankitrox! LGTM ✅

Copy link
Collaborator

@techanvil techanvil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @ankitrox, this is most of the way there. I've left a few minor comments, please take a look.

'complete_module_setup',
moduleSlug
);
const completionEventArgs = isInitialSetupFlow
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @ankitrox, thanks for explaining your rationale here, however, I would agree with @abdelmalekkkkk that it would be more readable to use an if/else. It won't result in calling trackEvent() twice, simply writing it twice, which seems fine when considering the improved legibility:

			if ( isInitialSetupFlow ) {
				await trackEvent(
					`${ viewContext }_setup`,
					'setup_flow_v3_complete_analytics_step'
				);
			} else {
				await trackEvent(
					'moduleSetup',
					'complete_module_setup',
					moduleSlug
				);
			}

'proxy'
);

const createAccountEventArgs = isInitialSetupFlow
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My reply above also applies here, please do update this to use an if/else.

@ankitrox
Copy link
Collaborator Author

@techanvil Thanks for reviewing the PR and providing the valuable feedback.

I've addressed the changes you suggested and sending your way for another pass.

Copy link
Collaborator

@techanvil techanvil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @ankitrox!

I've left one more minor comment, also there's a merge conflict that needs to be resolved.

let registry;

beforeEach( () => {
mockTrackEvent.mockClear();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As per my other comment, please move this line to an afterEach() callback.

@abdelmalekkkkk abdelmalekkkkk mentioned this pull request Nov 24, 2025
19 tasks
Copy link
Collaborator

@techanvil techanvil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks @ankitrox!

@techanvil techanvil merged commit 7756790 into develop Nov 25, 2025
27 of 28 checks passed
@techanvil techanvil deleted the enhancement/11722-ga-event-analytics-setup branch November 25, 2025 10:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants