Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable labeling of Ads campaigns #2485

Merged
merged 14 commits into from
Aug 1, 2024
Merged

Enable labeling of Ads campaigns #2485

merged 14 commits into from
Aug 1, 2024

Conversation

jorgemd24
Copy link
Contributor

@jorgemd24 jorgemd24 commented Jul 31, 2024

Changes proposed in this Pull Request:

Part of pcTzPl-2nS-p2

We would like to track where campaigns are created from by labeling them with their source of creation. For example, use wc-gla for the web version, and for the mobile versions, something like wc-gla-android or wc-gla-ios.

This PR allows the creation of a new campaign with a specific label. Note that I haven't updated the frontend to send the label query parameter yet, as I would first like to define the label names we'll be using.

Screenshots:

Detailed test instructions:

  1. Make the following call POST wp-json/wc/gla/ads/campaigns with this body:
{
    "amount": 0.01,
    "targeted_locations": ["ES"],
    "label": "wc-gla"
}
  1. The campaign should be created successfully.
  2. Go to https://ads.google.com/
  3. Filter your campaign by label:

image

You should see the campaign that you just created.
6. Alternatively, you can customize the campaigns table to display the labels:

image

image

image

Additional details:

Changelog entry

Add - Enable labeling of Ads campaigns

@github-actions github-actions bot added type: enhancement The issue is a request for an enhancement. changelog: add A new feature, function, or functionality was added. labels Jul 31, 2024
@jorgemd24 jorgemd24 self-assigned this Jul 31, 2024
Copy link

codecov bot commented Jul 31, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 64.9%. Comparing base (f398161) to head (10d296c).

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##             develop   #2485     +/-   ##
===========================================
+ Coverage       64.5%   64.9%   +0.4%     
- Complexity      4564    4575     +11     
===========================================
  Files            795     475    -320     
  Lines          22844   17856   -4988     
  Branches        1220       0   -1220     
===========================================
- Hits           14739   11590   -3149     
+ Misses          7938    6266   -1672     
+ Partials         167       0    -167     
Flag Coverage Δ
js-unit-tests ?
php-unit-tests 64.9% <100.0%> (+0.1%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
src/API/Google/AdsCampaign.php 97.2% <100.0%> (+<0.1%) ⬆️
src/API/Google/AdsCampaignLabel.php 100.0% <100.0%> (ø)
src/API/Google/Query/AdsCampaignLabelQuery.php 100.0% <100.0%> (ø)
...rc/API/Site/Controllers/Ads/CampaignController.php 100.0% <100.0%> (ø)
...nal/DependencyManagement/GoogleServiceProvider.php 94.8% <100.0%> (+<0.1%) ⬆️

... and 322 files with indirect coverage changes

@jorgemd24 jorgemd24 changed the title Allow to add campaign labels Enable labeling of Ads campaigns Jul 31, 2024
@jorgemd24 jorgemd24 requested a review from a team July 31, 2024 09:23
@jorgemd24 jorgemd24 marked this pull request as ready for review July 31, 2024 09:35
Copy link
Contributor

@martynmjones martynmjones left a comment

Choose a reason for hiding this comment

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

Hey @jorgemd24, thanks for adding the label functionality 🙌

Confirmed that the label is created and assigned to the campaign.

Screenshot 2024-08-01 at 19 30 11

I left one question but there aren't any issues so LGTM ✅

Comment on lines 69 to 75
$label_id = null;

foreach ( $label_results->iterateAllElements() as $row ) {
return $row->getLabel()->getId();
}

return $label_id;
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm curious why you decided to create the $label_id variable instead of just returning null after the loop?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep that's true, it is unnecessary, I removed it here d30851d

@jorgemd24 jorgemd24 merged commit bc8435a into develop Aug 1, 2024
10 checks passed
@jorgemd24 jorgemd24 deleted the add/campaign-labels branch August 1, 2024 20:47
@ianlin ianlin mentioned this pull request Aug 6, 2024
22 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog: add A new feature, function, or functionality was added. type: enhancement The issue is a request for an enhancement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants