From d6db04de7f56d9db7044a26551aea5d99c8e0c67 Mon Sep 17 00:00:00 2001 From: Miguel Perez Pellicer <5908855+puntope@users.noreply.github.com> Date: Thu, 30 Nov 2023 20:12:45 -0300 Subject: [PATCH 1/3] Add (budget and audiences) tracking for Onboarding completed with Ads --- .../setup-paid-ads/setup-paid-ads.js | 15 +++++++++++++ src/Tracking/README.md | 22 ++++++++++++++----- 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/js/src/setup-mc/setup-stepper/setup-paid-ads/setup-paid-ads.js b/js/src/setup-mc/setup-stepper/setup-paid-ads/setup-paid-ads.js index 8bc19b9dfa..8fb9a41865 100644 --- a/js/src/setup-mc/setup-stepper/setup-paid-ads/setup-paid-ads.js +++ b/js/src/setup-mc/setup-stepper/setup-paid-ads/setup-paid-ads.js @@ -7,6 +7,7 @@ import { select } from '@wordpress/data'; import { useState } from '@wordpress/element'; import { Flex } from '@wordpress/components'; import { noop, merge } from 'lodash'; +import { recordEvent } from '@woocommerce/tracks'; /** * Internal dependencies @@ -42,6 +43,14 @@ const ACTION_SKIP = 'skip-ads'; * @event gla_onboarding_complete_with_paid_ads_button_click */ +/** + * When the Onboarding is completed with Ads Setup. + * + * @event gla_onboarding_complete_ads_setup + * @property {number} budget The budget for the campaign + * @property {number} audiences The targeted audiences for the campaign + */ + /** * Clicking on the skip paid ads button to complete the onboarding flow. * The 'unknown' value of properties may means: @@ -63,6 +72,7 @@ const ACTION_SKIP = 'skip-ads'; * @fires gla_onboarding_open_paid_ads_setup_button_click * @fires gla_onboarding_complete_with_paid_ads_button_click * @fires gla_onboarding_complete_button_click + * @fires gla_onboarding_complete_ads_setup */ export default function SetupPaidAds() { const adminUrl = useAdminUrl(); @@ -100,6 +110,11 @@ export default function SetupPaidAds() { ); } + recordEvent( 'gla_onboarding_complete_ads_setup', { + budget: paidAds.amount, + audiences: paidAds.countryCodes.join( ',' ), + } ); + // Force reload WC admin page to initiate the relevant dependencies of the Dashboard page. const query = { guide: GUIDE_NAMES.SUBMISSION_SUCCESS }; window.location.href = adminUrl + getProductFeedUrl( query ); diff --git a/src/Tracking/README.md b/src/Tracking/README.md index 3a301c3238..bc7ebc3556 100644 --- a/src/Tracking/README.md +++ b/src/Tracking/README.md @@ -571,7 +571,17 @@ A modal is open - [`ReviewRequest`](../../js/src/product-feed/review-request/index.js#L31) with `context: REQUEST_REVIEW` - [`SubmissionSuccessGuide`](../../js/src/product-feed/submission-success-guide/index.js#L155) with `context: GUIDE_NAMES.SUBMISSION_SUCCESS` -### [`gla_onboarding_complete_button_click`](../../js/src/setup-mc/setup-stepper/setup-paid-ads/setup-paid-ads.js#L45) +### [`gla_onboarding_complete_ads_setup`](../../js/src/setup-mc/setup-stepper/setup-paid-ads/setup-paid-ads.js#L46) +When the Onboarding is completed with Ads Setup. +#### Properties +| name | type | description | +| ---- | ---- | ----------- | +`budget` | `number` | The budget for the campaign +`audiences` | `number` | The targeted audiences for the campaign +#### Emitters +- [`exports`](../../js/src/setup-mc/setup-stepper/setup-paid-ads/setup-paid-ads.js#L77) + +### [`gla_onboarding_complete_button_click`](../../js/src/setup-mc/setup-stepper/setup-paid-ads/setup-paid-ads.js#L54) Clicking on the skip paid ads button to complete the onboarding flow. The 'unknown' value of properties may means: - the paid ads setup is not opened @@ -585,17 +595,17 @@ Clicking on the skip paid ads button to complete the onboarding flow. `billing_method_status` | `string` | aaa, The status of billing method of merchant's Google Ads addcount e.g. 'unknown', 'pending', 'approved', 'cancelled' `campaign_form_validation` | `string` | Whether the entered paid campaign form data are valid, e.g. 'unknown', 'valid', 'invalid' #### Emitters -- [`exports`](../../js/src/setup-mc/setup-stepper/setup-paid-ads/setup-paid-ads.js#L67) +- [`exports`](../../js/src/setup-mc/setup-stepper/setup-paid-ads/setup-paid-ads.js#L77) -### [`gla_onboarding_complete_with_paid_ads_button_click`](../../js/src/setup-mc/setup-stepper/setup-paid-ads/setup-paid-ads.js#L39) +### [`gla_onboarding_complete_with_paid_ads_button_click`](../../js/src/setup-mc/setup-stepper/setup-paid-ads/setup-paid-ads.js#L40) Clicking on the "Complete setup" button to complete the onboarding flow with paid ads. #### Emitters -- [`exports`](../../js/src/setup-mc/setup-stepper/setup-paid-ads/setup-paid-ads.js#L67) +- [`exports`](../../js/src/setup-mc/setup-stepper/setup-paid-ads/setup-paid-ads.js#L77) -### [`gla_onboarding_open_paid_ads_setup_button_click`](../../js/src/setup-mc/setup-stepper/setup-paid-ads/setup-paid-ads.js#L33) +### [`gla_onboarding_open_paid_ads_setup_button_click`](../../js/src/setup-mc/setup-stepper/setup-paid-ads/setup-paid-ads.js#L34) Clicking on the "Create a paid ad campaign" button to open the paid ads setup in the onboarding flow. #### Emitters -- [`exports`](../../js/src/setup-mc/setup-stepper/setup-paid-ads/setup-paid-ads.js#L67) +- [`exports`](../../js/src/setup-mc/setup-stepper/setup-paid-ads/setup-paid-ads.js#L77) ### [`gla_paid_campaign_step`](../../js/src/utils/recordEvent.js#L122) Triggered when moving to another step during creating/editing a campaign. From dfe892054b57304ee44f23ee29ecdb74a9b59088 Mon Sep 17 00:00:00 2001 From: Miguel Perez Pellicer <5908855+puntope@users.noreply.github.com> Date: Mon, 11 Dec 2023 18:21:01 -0300 Subject: [PATCH 2/3] Add audiences and budget inside existing gla_onboarding_complete_with_paid_ads_button_click --- .../setup-paid-ads/setup-paid-ads.js | 19 ++++--------- src/Tracking/README.md | 27 ++++++++----------- 2 files changed, 16 insertions(+), 30 deletions(-) diff --git a/js/src/setup-mc/setup-stepper/setup-paid-ads/setup-paid-ads.js b/js/src/setup-mc/setup-stepper/setup-paid-ads/setup-paid-ads.js index 8fb9a41865..a28a7b78ab 100644 --- a/js/src/setup-mc/setup-stepper/setup-paid-ads/setup-paid-ads.js +++ b/js/src/setup-mc/setup-stepper/setup-paid-ads/setup-paid-ads.js @@ -7,7 +7,6 @@ import { select } from '@wordpress/data'; import { useState } from '@wordpress/element'; import { Flex } from '@wordpress/components'; import { noop, merge } from 'lodash'; -import { recordEvent } from '@woocommerce/tracks'; /** * Internal dependencies @@ -41,14 +40,8 @@ const ACTION_SKIP = 'skip-ads'; * Clicking on the "Complete setup" button to complete the onboarding flow with paid ads. * * @event gla_onboarding_complete_with_paid_ads_button_click - */ - -/** - * When the Onboarding is completed with Ads Setup. - * - * @event gla_onboarding_complete_ads_setup * @property {number} budget The budget for the campaign - * @property {number} audiences The targeted audiences for the campaign + * @property {string} audiences The targeted audiences for the campaign */ /** @@ -72,7 +65,6 @@ const ACTION_SKIP = 'skip-ads'; * @fires gla_onboarding_open_paid_ads_setup_button_click * @fires gla_onboarding_complete_with_paid_ads_button_click * @fires gla_onboarding_complete_button_click - * @fires gla_onboarding_complete_ads_setup */ export default function SetupPaidAds() { const adminUrl = useAdminUrl(); @@ -110,11 +102,6 @@ export default function SetupPaidAds() { ); } - recordEvent( 'gla_onboarding_complete_ads_setup', { - budget: paidAds.amount, - audiences: paidAds.countryCodes.join( ',' ), - } ); - // Force reload WC admin page to initiate the relevant dependencies of the Dashboard page. const query = { guide: GUIDE_NAMES.SUBMISSION_SUCCESS }; window.location.href = adminUrl + getProductFeedUrl( query ); @@ -222,6 +209,10 @@ export default function SetupPaidAds() { disabled={ disabledComplete } onClick={ handleCompleteClick } eventName="gla_onboarding_complete_with_paid_ads_button_click" + eventProps={ { + budget: paidAds.amount, + audiences: paidAds.countryCodes.join( ',' ), + } } /> diff --git a/src/Tracking/README.md b/src/Tracking/README.md index bc7ebc3556..b8104759e5 100644 --- a/src/Tracking/README.md +++ b/src/Tracking/README.md @@ -571,17 +571,7 @@ A modal is open - [`ReviewRequest`](../../js/src/product-feed/review-request/index.js#L31) with `context: REQUEST_REVIEW` - [`SubmissionSuccessGuide`](../../js/src/product-feed/submission-success-guide/index.js#L155) with `context: GUIDE_NAMES.SUBMISSION_SUCCESS` -### [`gla_onboarding_complete_ads_setup`](../../js/src/setup-mc/setup-stepper/setup-paid-ads/setup-paid-ads.js#L46) -When the Onboarding is completed with Ads Setup. -#### Properties -| name | type | description | -| ---- | ---- | ----------- | -`budget` | `number` | The budget for the campaign -`audiences` | `number` | The targeted audiences for the campaign -#### Emitters -- [`exports`](../../js/src/setup-mc/setup-stepper/setup-paid-ads/setup-paid-ads.js#L77) - -### [`gla_onboarding_complete_button_click`](../../js/src/setup-mc/setup-stepper/setup-paid-ads/setup-paid-ads.js#L54) +### [`gla_onboarding_complete_button_click`](../../js/src/setup-mc/setup-stepper/setup-paid-ads/setup-paid-ads.js#L47) Clicking on the skip paid ads button to complete the onboarding flow. The 'unknown' value of properties may means: - the paid ads setup is not opened @@ -595,17 +585,22 @@ Clicking on the skip paid ads button to complete the onboarding flow. `billing_method_status` | `string` | aaa, The status of billing method of merchant's Google Ads addcount e.g. 'unknown', 'pending', 'approved', 'cancelled' `campaign_form_validation` | `string` | Whether the entered paid campaign form data are valid, e.g. 'unknown', 'valid', 'invalid' #### Emitters -- [`exports`](../../js/src/setup-mc/setup-stepper/setup-paid-ads/setup-paid-ads.js#L77) +- [`exports`](../../js/src/setup-mc/setup-stepper/setup-paid-ads/setup-paid-ads.js#L69) -### [`gla_onboarding_complete_with_paid_ads_button_click`](../../js/src/setup-mc/setup-stepper/setup-paid-ads/setup-paid-ads.js#L40) +### [`gla_onboarding_complete_with_paid_ads_button_click`](../../js/src/setup-mc/setup-stepper/setup-paid-ads/setup-paid-ads.js#L39) Clicking on the "Complete setup" button to complete the onboarding flow with paid ads. +#### Properties +| name | type | description | +| ---- | ---- | ----------- | +`budget` | `number` | The budget for the campaign +`audiences` | `string` | The targeted audiences for the campaign #### Emitters -- [`exports`](../../js/src/setup-mc/setup-stepper/setup-paid-ads/setup-paid-ads.js#L77) +- [`exports`](../../js/src/setup-mc/setup-stepper/setup-paid-ads/setup-paid-ads.js#L69) -### [`gla_onboarding_open_paid_ads_setup_button_click`](../../js/src/setup-mc/setup-stepper/setup-paid-ads/setup-paid-ads.js#L34) +### [`gla_onboarding_open_paid_ads_setup_button_click`](../../js/src/setup-mc/setup-stepper/setup-paid-ads/setup-paid-ads.js#L33) Clicking on the "Create a paid ad campaign" button to open the paid ads setup in the onboarding flow. #### Emitters -- [`exports`](../../js/src/setup-mc/setup-stepper/setup-paid-ads/setup-paid-ads.js#L77) +- [`exports`](../../js/src/setup-mc/setup-stepper/setup-paid-ads/setup-paid-ads.js#L69) ### [`gla_paid_campaign_step`](../../js/src/utils/recordEvent.js#L122) Triggered when moving to another step during creating/editing a campaign. From 7c7ee8775f1af1b42ae1c88eb16a66611f75b4bf Mon Sep 17 00:00:00 2001 From: Miguel Perez Pellicer <5908855+puntope@users.noreply.github.com> Date: Tue, 12 Dec 2023 11:19:45 -0300 Subject: [PATCH 3/3] Prevent undefined country codes --- js/src/setup-mc/setup-stepper/setup-paid-ads/setup-paid-ads.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/src/setup-mc/setup-stepper/setup-paid-ads/setup-paid-ads.js b/js/src/setup-mc/setup-stepper/setup-paid-ads/setup-paid-ads.js index a28a7b78ab..634a134d5e 100644 --- a/js/src/setup-mc/setup-stepper/setup-paid-ads/setup-paid-ads.js +++ b/js/src/setup-mc/setup-stepper/setup-paid-ads/setup-paid-ads.js @@ -211,7 +211,7 @@ export default function SetupPaidAds() { eventName="gla_onboarding_complete_with_paid_ads_button_click" eventProps={ { budget: paidAds.amount, - audiences: paidAds.countryCodes.join( ',' ), + audiences: paidAds.countryCodes?.join( ',' ), } } />