-
Notifications
You must be signed in to change notification settings - Fork 500
Added 2 Important Examples for New Feature Budget Recommendations #905
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
Conversation
client: an initialized GoogleAdsClient instance. | ||
customer_id: a client customer ID. | ||
""" | ||
# Start Recommendation Service. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment doesn't add value, can you remove it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do!
# Start Recommendation Service. | ||
recommendation_service = client.get_service("RecommendationService") | ||
|
||
# Build Request. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you remove this comment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do!
request.positive_locations_ids = [2840] # 2840 is for United States | ||
request.asset_group_info = [{ "final_url": "https://www.your-company.com/" }] | ||
|
||
# Send Request. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you remove this comment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do!
|
||
# Get budget recommendations with their associated impact metrics. | ||
for rec in recommendations: | ||
if hasattr(rec, 'campaign_budget_recommendation'): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this check actually necessary, if you're only generating CAMPAIGN_BUDGET recommendations?
I think it might be helpful to keep it regardless, for the sake of example, but if it's not necessary here I'd comment it out and add an explanation like "Check whether this is a campaign budget recommendation. This isn't needed when we're only generating recommendations of a single type, but it demonstrates how you could check on the recommendation type when generating recommendations of multiple types."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, it's possible that the API responds with no recommendations. We don't know how often this happens, but it's a possibility. It happens. That's why I'm checking here if there are budget recommendations.
I'll add a comment above the "if" saying "Check if the API responded with recommendations".
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is the case, wouldn't recommendations
itself be empty?
# limitations under the License. | ||
"""This example is to get impact metrics for a custom budget. | ||
|
||
Use this example to get impact metrics for a budget amount during campaign creation workflows. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: "for a given budget amount"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do
from google.ads.googleads.errors import GoogleAdsException | ||
|
||
|
||
def main(client, customer_id, budget_amount_user): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
budget_amount_user is a little bit of a confusing variable name, to me. Can we just say "budget_amount"? Or if you feel like it needs to be said that it's a user value, "user_provided_budget_amount"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect, good suggestion. I'll change it to "user_provided_budget_amount" so it's clearer.
Args: | ||
client: an initialized GoogleAdsClient instance. | ||
customer_id: a client customer ID. | ||
budget_amount_user: a budget amount (not in micros) advertiser wants to use. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you update the description to "a user-provided budget amount (not in micros), to retrieve impact metrics for."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do
customer_id: a client customer ID. | ||
budget_amount_user: a budget amount (not in micros) advertiser wants to use. | ||
""" | ||
# Start Recommendation Service. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you remove the comments I pointed out in the other example?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Absolutely!
This example uses the following: | ||
1) Performance Max for the campaign type | ||
2) United States for the geo targeting | ||
3) Maximize Conversions Value for the bidding strategy |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Conversion (no s)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
budget_recommendations_list.append(budget_data) | ||
budget_amounts.append(round((budget_amount/1000000), 2)) | ||
else: | ||
print("campaign_budget_recommendation not found for this account.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Related to my other comment: the if
statement is at the recommendation level. But in theory, if there are no recommendations, wouldn't we not even get to the if
/else
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right. The object will be empty if there's not recommendation, so we can skip the if/else altogether. Thanks!!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a few additional comments that need to be addressed before I can approve! Thanks for making the updates so far, it's already much more readable from my perspective.
print(f"budget_impact_metrics:\n{budget_impact_metrics}") | ||
""" | ||
budget_impact_metrics: | ||
[{'budget_amount': 100.0, 'potential_metrics': cost_micros: 700000000 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should 'potential_metrics'
be a nested dict here? Or is this how it gets printed?
On that note, I recommend running these examples once more (if you haven't already) to make sure it's working as expected!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's how it gets printed. And yes, I run final tests for both examples after all the edits and it works like a charm! hahah
print(f"budget_recommendations_list:\n{budget_recommendations_list}") | ||
""" | ||
budget_recommendations_list: | ||
[{'budget_amount': 44.56, 'potential_metrics': cost_micros: 311920000 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as in the other file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same answer as in the other. That's how it gets printed, and I ran tests for both examples after all the edits and works perfectly
I've added 2 important examples of the new feature Budget Recommendations, which was launched in Google Ads API v18.
I've iterated based on Laura's feedback (@laurachevalier4 ). I had to create a new PR and I closed the previous one (#904 ).
If you have feedback, please let me know and I can work on the changes, but don't change the PR as it complicates things on my end. Thanks!