Repository navigation
Add get_campaign_settings - #111
Merged
Merged
Conversation
One read-only call returning every setting that decides how far a Search campaign reaches: networks, location option, campaign-level broad match, bidding and budget, URL options, and the AI Max state from read_ai_max_state. Each campaign lists its widening_settings and insights[] names the campaigns that have any, so a recurring audit is one call that diffs cleanly. Closes kLOsk#109.
kLOsk
reviewed
Oct 27, 2026
kLOsk
left a comment
Owner
There was a problem hiding this comment.
Really useful, and a clean read-back for #104 to #106. Three small things:
campaign.network_settings.target_partner_search_networkis selected but not used, so either drop it or surface it.- With an explicit
campaign_idthe Search filter falls away, so a PMax ID returns a record whose AI Max fields don't apply: keepadvertising_channel_type = 'SEARCH'in that branch, or say in the docstring that any channel is returned. - Two blank lines before the next
@_tool.
Happy to merge after that.
kLOsk
added a commit
that referenced
this pull request
Oct 27, 2026
…used field Follow-up to #111 (the review notes): with a campaign_id the query no longer drops the Search filter, so a Performance Max or Display ID comes back empty instead of as a record whose AI Max and location fields don't apply; target_partner_search_network was selected but never used; PEP 8 spacing before the next tool. Co-Authored-By: xgp <xgp@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TiC3mRmhzUVXgCexry7GJ3
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #109.
Adds the read-only tool
get_campaign_settings. It returns one flat record per non-removed Search campaign (or just the one incampaign_id) with every setting that decides how far the campaign reaches. That turns a weekly "did Google switch something back on?" audit into a single call that diffs cleanly week to week.Fields
All of them are on the v25
Campaign/CampaignBudgetresources, in one GAQL query:bidding_strategy_type,portfolio_bidding_strategycampaign.bidding_strategy_type,campaign.bidding_strategycpc_bid_ceiling,target_cpa,target_roastarget_spend.cpc_bid_ceiling_micros,target_cpa/maximize_conversions.target_cpa_micros,target_roas/maximize_conversion_value.target_roasdaily_budget,budget_sharedcampaign_budget.amount_micros,explicitly_sharedgoogle_search,search_partners,display_networknetwork_settings.*location_option,negative_location_optiongeo_target_type_setting.positive_geo_target_type/negative_geo_target_typekeyword_match_typecampaign.keyword_match_typetracking_url_template,final_url_suffix,url_custom_parametersThe AI Max half (
enable_ai_max,asset_automationper type) comes straight fromai_max.read_ai_max_state, so this tool andget_ai_max_settingscan never disagree.Money is converted from micros and labelled with
currencyfromget_currency_code.widening_settingsandinsights[]Each record lists the settings that let ads reach beyond the chosen keywords and locations:
PRESENCE_OR_INTERESTorSEARCH_INTERESTlocation optionOPTED_INinsights[]names each campaign that has any.ad_groups_with_search_term_matchingis only filled when AI Max is on, because every ad group defaults toFalseand the flag does nothing without AI Max.This is also the read-back the write-side issues (#104 location option, #105 URL options, #106 broad match) would use, so none of them needs GAQL to verify.
Verified against a live account
I ran it read-only against a live account with two paused Search campaigns built through AdLoop. Both came back with
widening_settings: ["location option PRESENCE_OR_INTEREST"], the API default that #104 is about, and nothing else.Tests
There are 12 new tests in
tests/test_campaign_settings.py, none of them hitting the live API:SEARCH_INTERESTcampaign_idrefused before any client is built (same rule as Add AI Max controls: prepare Search campaigns for brand exclusions #77)One more test walks every selected field against the SDK's own v25
Campaign/CampaignBudgetprotos, so a renamed field fails in CI rather than withUNRECOGNIZED_FIELDin someone's account. I mutation-checked it with a misspelled field.Baseline on
mainwas 1624 passed, 2 skipped. This branch is independent of #110.I haven't regenerated
adloop-docs/reference/tools.mdx; I can open that PR inadloop-docsonce this one is settled.