woocommerce / google-listings-and-ads

Sync your store with Google to list products for free, run paid ads, and track performance straight from your store dashboard.
https://woo.com/products/google-listings-and-ads/
GNU General Public License v3.0
47 stars 21 forks source link

Improve post-onboarding: Show promotion for Google Ads campaign on the Product Feed page #2641

Closed kt-12 closed 3 weeks ago

kt-12 commented 1 month ago

Changes proposed in this Pull Request:

Closes #2539

Replace this with a good description of your changes & reasoning.

Screenshots:

When there is Product but no campaign: ( Show the notice )

no-campaign no-campaign-yes-notice

When there is Product and a campaign: ( Don't show the notice )

campaign when-there-is-campaign

Detailed test instructions:

  1. Create a Simple Product, sync to merchant account.
  2. Visit Dashboard > Product Feed
  3. If there is one active ( approved or partially approved) product and no campaign, notice will be shown. Check screenshots.
  4. Click on the button and add campaign. Once added revisit Product Feed page and this section should disappear.

Additional details:

Further more this ticket address a bug in useAdsCampaign https://github.com/woocommerce/google-listings-and-ads/issues/2539#issuecomment-2397847396, which required certain E2E to be adjusted.

Changelog entry

Add - Show promotion for Google Ads campaign on the Product Feed page.

codecov[bot] commented 1 month ago

Codecov Report

Attention: Patch coverage is 77.77778% with 2 lines in your changes missing coverage. Please review.

Project coverage is 63.5%. Comparing base (3553804) to head (616756f). Report is 195 commits behind head on feature/2460-google-ads-value-prop.

Files with missing lines Patch % Lines
...product-statistics/create-campaign-notice/index.js 77.8% 2 Missing :warning:
Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/woocommerce/google-listings-and-ads/pull/2641/graphs/tree.svg?width=650&height=150&src=pr&token=UROWUPF1LX&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=woocommerce)](https://app.codecov.io/gh/woocommerce/google-listings-and-ads/pull/2641?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=woocommerce) ```diff @@ Coverage Diff @@ ## feature/2460-google-ads-value-prop #2641 +/- ## ======================================================================= - Coverage 65.1% 63.5% -1.6% ======================================================================= Files 800 331 -469 Lines 24300 5214 -19086 Branches 1244 1273 +29 ======================================================================= - Hits 15831 3313 -12518 + Misses 8287 1723 -6564 + Partials 182 178 -4 ``` | [Flag](https://app.codecov.io/gh/woocommerce/google-listings-and-ads/pull/2641/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=woocommerce) | Coverage Δ | | |---|---|---| | [js-unit-tests](https://app.codecov.io/gh/woocommerce/google-listings-and-ads/pull/2641/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=woocommerce) | `63.5% <77.8%> (+1.5%)` | :arrow_up: | | [php-unit-tests](https://app.codecov.io/gh/woocommerce/google-listings-and-ads/pull/2641/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=woocommerce) | `?` | | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=woocommerce#carryforward-flags-in-the-pull-request-comment) to find out more. | [Files with missing lines](https://app.codecov.io/gh/woocommerce/google-listings-and-ads/pull/2641?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=woocommerce) | Coverage Δ | | |---|---|---| | [js/src/product-feed/product-statistics/index.js](https://app.codecov.io/gh/woocommerce/google-listings-and-ads/pull/2641?src=pr&el=tree&filepath=js%2Fsrc%2Fproduct-feed%2Fproduct-statistics%2Findex.js&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=woocommerce#diff-anMvc3JjL3Byb2R1Y3QtZmVlZC9wcm9kdWN0LXN0YXRpc3RpY3MvaW5kZXguanM=) | `95.7% <ø> (ø)` | | | [...product-statistics/create-campaign-notice/index.js](https://app.codecov.io/gh/woocommerce/google-listings-and-ads/pull/2641?src=pr&el=tree&filepath=js%2Fsrc%2Fproduct-feed%2Fproduct-statistics%2Fcreate-campaign-notice%2Findex.js&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=woocommerce#diff-anMvc3JjL3Byb2R1Y3QtZmVlZC9wcm9kdWN0LXN0YXRpc3RpY3MvY3JlYXRlLWNhbXBhaWduLW5vdGljZS9pbmRleC5qcw==) | `77.8% <77.8%> (ø)` | | ... and [498 files with indirect coverage changes](https://app.codecov.io/gh/woocommerce/google-listings-and-ads/pull/2641/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=woocommerce)
ankitguptaindia commented 1 month ago

QA/Test Report-

Testing Environment -

* WordPress: 6.6.2 * Theme active on store: Twenty Twenty-Four Version: 1.2 * WooCommerce - Version 9.3.2 * PHP: 8.3 * Web Server: Nginx * Browser: Chrome - Version 128 * OS: macOS Sonoma 14.6.1

Test Results -

When No Paid Campaign available -

image

When Paid Campaign Available -

image

Paid campaign creation flow from Notice button:

https://github.com/user-attachments/assets/15a66c7e-d27e-4bb8-bf5f-75517245bfac

joemcgill commented 1 month ago

@eason9487 thanks for the review, we're working through the feedback. Regarding this:

In terms of the requirement, does useAdsCampaigns need to be changed?

I do think that useAdsCampaigns needs to be changed for this requirement.

The purpose of this issue is to encourage merchants to create their first campaign but only if they have approved products and do not already have any ads campaigns created. To verify whether ads campaigns are running we need to check for existing campaigns on the account, which is what this hook seems to be for. However, if someone connects an existing account that already has ads and finishes onboarding by skipping creating a new ad, then the request to see if the account already has ads will never run.

This can be verified by connecting an account and creating a campaign.

image

Then from the settings screen, disconnect the account and reconnect it through the setup-ads flow and close without creating a new campaign. At this point, no more campaigns will show on the dashboard because no ads will be returned from the useAdsCampaigns hook, even though the account does have campaigns running.

image

This does not seem like expected behavior to me.

eason9487 commented 1 month ago

Hi @joemcgill

I do think that useAdsCampaigns needs to be changed for this requirement.

Other side effects from changing useAdsCampaigns will need to be reviewed one by one to see if they need to be adjusted together, otherwise there may be inconsistent presentation at a high level.

For example, the campaign list is displayed on the Dashboard page, but the Performance card on the same page still doesn't show campaign performance data.

It's also possible that a merchant has connected to a Google Ads account with existing campaigns but has not completed the Ads Setup flow for a long time. The adsSetupComplete will be always false and ADS_SETUP_COMPLETED_AT doesn't exist. The frontend and backend logic associated with these two values will also be affected and may need to be reviewed one by one as well.

joemcgill commented 1 month ago

Other side effects from changing useAdsCampaigns will need to be reviewed one by one to see if they need to be adjusted together, otherwise there may be inconsistent presentation at a high level.

That makes sense. I've reviewed the codebase and am documenting my observations here for posterity.

It looks like all of the functionality that depends on the gla.adsSetupComplete global, including the useAdsCampaigns() hook assume that there are no campaigns to display until after the Ads account has been fully set up via the onboarding process or the secondary "Set up paid ads" flow. In both cases, "fully set up" means that an ad campaign has been created (not just that the Ads account has been connected).

The only way that global is getting set is firing the useAdsSetupCompleteCallback() hook here and here. Which make a POST request to the ads/setup/complete endpoint, resulting in the gla_ads_setup_completed_at option in the DB being set. Then, on a new page load, that option is checked to set the global via an inline script set here.

This means that as far as the plugin is concerned, you're not able to see and manage campaigns until you've created a new campaign after connecting the account (even if you reconnect an account you were previously using).

That limitation should probably be resolved, IMO, but that is well beyond the scope of what we're trying to solve here or in #2538. So for consistency, I think we'll keep useAdsCampaigns() hook as it was prior to our changes and make our new functionality for these issues work from the same assumption—i.e., that no campaigns are known until after a new campaign is created after connecting the Ads account.

I can log a new issue for the broader updates that we can look at coming back to.