google-listings-and-ads icon indicating copy to clipboard operation
google-listings-and-ads copied to clipboard

Show promo for setting up Google Ads on reports and product feed tabs

Open joemcgill opened this issue 1 year ago • 1 comments

joemcgill avatar Aug 16 '24 21:08 joemcgill

This will likely be blocked until #2599 is resolved.

joemcgill avatar Sep 10 '24 19:09 joemcgill

@joemcgill I've added the IB. Can you kindly take a look and let me know please?

asvinb avatar Oct 03 '24 10:10 asvinb

There is an existing issue with useAdsCampaigns that was discovered in https://github.com/woocommerce/google-listings-and-ads/pull/2242#issuecomment-2026060492, where the hook will not fetch existing Ads accounts in certain circumstances.

I think we can fix this by replacing the TODO comment in the useAdsCampaign hook with a check for whether there is a Google Ads connection. Here's the idea:

diff --git a/js/src/hooks/useAdsCampaigns.js b/js/src/hooks/useAdsCampaigns.js
index 5975aec45..235b12a6a 100644
--- a/js/src/hooks/useAdsCampaigns.js
+++ b/js/src/hooks/useAdsCampaigns.js
@@ -7,7 +7,7 @@ import { useSelect } from '@wordpress/data';
  * Internal dependencies
  */
 import { STORE_KEY } from '.~/data';
-import { glaData } from '.~/constants';
+import useGoogleAdsAccount from '.~/hooks/useGoogleAdsAccount';
 import useIsEqualRefValue from '.~/hooks/useIsEqualRefValue';
 
 const selectorName = 'getAdsCampaigns';
@@ -30,16 +30,12 @@ const selectorName = 'getAdsCampaigns';
  */
 const useAdsCampaigns = ( ...query ) => {
 	const queryRefValue = useIsEqualRefValue( query );
+	const { hasGoogleAdsConnection, hasFinishedResolution } =
+		useGoogleAdsAccount();
 
 	return useSelect(
 		( select ) => {
-			// TODO: ideally adsSetupComplete should be retrieved from API endpoint
-			// and then put into wp-data.
-			// With that in place, then we don't need to depend on glaData
-			// which requires force reload using window.location.href.
-			const { adsSetupComplete } = glaData;
-
-			if ( ! adsSetupComplete ) {
+			if ( hasFinishedResolution && ! hasGoogleAdsConnection ) {
 				return {
 					loading: false,
 					loaded: true,

joemcgill avatar Oct 07 '24 20:10 joemcgill

I think we should reuse the AddPaidCampaignButton component directly here, rather than creating a different one. I've added info about what eventProps name to add, which we can change later based on feedback during WooCR (cc: @eason9487).

joemcgill avatar Oct 07 '24 21:10 joemcgill

The eventProps for this requirement could be { context: 'product-feed-overview-promotion' }

eason9487 avatar Oct 08 '24 04:10 eason9487

Closing this as completed since it was part of the 2.9 release.

mikkamp avatar Dec 02 '24 15:12 mikkamp