Repository navigation
Demand Gen campaigns and multi-asset image ads - #147
Merged
Merged
Conversation
draft_campaign(channel_type="DEMAND_GEN") builds budget + campaign (PAUSED) + one ad group in one mutate, following Google's Demand Gen guide: no ad group type, audience_setting.use_audience_grouped (immutable, needed to attach an Audience later), locations and languages on the ad group, channel controls, start and end date. Bidding: Maximize clicks, Maximize conversions, Target CPA. Optimized targeting is off by default. The field has no presence, so False cannot be sent on create, and Google refuses an update of a temporary id in the same request: it is switched off by a follow-up update, and a failure there raises PartialApplyError with the created resources so the plan is retired. draft_demand_gen_ad creates a DemandGenMultiAssetAdInfo ad (PAUSED) from library image assets, checking text lengths, each image's ratio for its slot against the account's assets, and the final URL. Google-generated videos and animated images are opted out on the ad unless asked for. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
palermomarco
added a commit
to palermomarco/adloop
that referenced
this pull request
Dec 1, 2026
Same changes as in kLOsk#147 and kLOsk#148: draft_audience is renamed draft_demand_gen_audience (operation create_demand_gen_audience), and a failed optimized-targeting follow-up after a Demand Gen create raises PartialApplyError so the plan is retired. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Conflicts with kLOsk#146 and kLOsk#148 in write.py (dispatch), card_view.py (effect lines) and server.py (tool registrations): both sides kept. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Jr3T22aqqRobKScfCwiyfY
Owner
|
Thanks, Marco. #146 and #148 are merged, which left this one with conflicts in I'll merge this now and follow up on main with a few things from the review, so you don't need to do another round:
One question, if you know it from your account: does a Demand Gen ad group without an audience serve to everyone in its locations, or not at all? The preview says it cannot serve, and I could not confirm that from Google's docs. |
kLOsk
added a commit
that referenced
this pull request
Dec 1, 2026
…, and a second confirmation for narrowing a running ad group Follow-up to #146, #147 and #148. draft_campaign refuses an argument it does not use instead of dropping it: start_date, end_date, channels and optimized_targeting on a Search campaign (an end date that is dropped leaves a campaign that never stops), and keywords, geo_exclude_ids, ad_schedule, target_roas and the network, location and URL options on a Demand Gen campaign. The Demand Gen branch also honours a blocked create_campaign. draft_demand_gen_ad takes tall portrait (9:16) images, which draft_library_image_assets already classifies, and checks that the ad group belongs to a Demand Gen campaign before it reads the images. draft_demand_gen_audience asks for a double confirmation when it attaches to an ad group that is running (campaign and ad group enabled), as targeting mode in draft_audience_attachment does: reach shrinks at once. The approval card states what creating a custom segment and creating or attaching an audience does. The campaign preview no longer says a campaign cannot serve without an audience, which Google's documentation does not state. The rules gain a Demand Gen pattern with the order of steps. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Jr3T22aqqRobKScfCwiyfY
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.
Third of the four PRs agreed in #142. It uses the asset ids from
draft_library_image_assets(#146), so it is most useful after that one; the code does not depend on it.What
draft_campaign(channel_type="DEMAND_GEN")builds budget + campaign (PAUSED) + one ad group in oneGoogleAdsService.Mutate, following Google's "Create a Demand Gen campaign" guide:DEMAND_GENwith no sub type.audience_setting.use_audience_grouped = true. It is immutable, and an Audience can only be attached to an ad group created with it (the next PR attaches one).channelssetsdemand_gen_ad_group_settings.channel_controls.selected_channels, stating every flag as Google asks. Empty leaves Google's default, all channels including the Display Network, and the preview warns.start_date/end_dateasstart_date_time/end_date_time.max_cpc), Maximize conversions, Target CPA. Budget cap, blocked operations and the usual checks apply.Optimized targeting is off by default.
optimized_targeting_enabledhas no presence, soFalseis not sent on create, and Google refuses an update of a temporary id inside the same request (RESOURCE_NOT_FOUND, found with validate-only). It is switched off with a follow-up update of the created ad group. As you suggested, a failure there raisesPartialApplyErrorwith the created budget, campaign and ad group, so the apply ends asPARTIAL_APPLYand the plan is retired.draft_demand_gen_adcreates aDemandGenMultiAssetAdInfoad (PAUSED) from library image assets:_counted_length).assetresource) and its ratio checked for its slot (±1%).final_urlchecked with_validate_urls; optionalcall_to_action.GENERATE_VIDEOS_FROM_OTHER_ASSETS,GENERATE_ANIMATED_IMAGES_FROM_OTHER_ASSETS), which then serve as extra ads. The tool opts the new ad out unlessgenerated_videos/animated_imagesis true. In Demand Gen this lives on the ad (AdGroupAd.ad_group_ad_asset_automation_settings): on the campaign Google answersVALUE_MUST_BE_UNSET.Operations
create_demand_gen_campaignandcreate_demand_gen_ad: dispatch, approval card lines (created paused), tool descriptions, and rules (.cursor/rules/adloop.mdc, synced).Tests
tests/test_demand_gen.py: draft validation for both tools (inputs, budget cap, blocked operation, text limits, image ratios against the library, unreachable URL), the campaign mutate (operation order, no ad group type,use_audience_grouped, criteria on the ad group, channel flags, bidding), the follow-up raisingPartialApplyError, the ad mutate (slots, PAUSED, asset automation opt-out).uv run pytest: 2632 passed, 2 skipped.Validate-only against a live account
confirm_and_apply(dry_run=True)on a real account; nothing was created:DRY_RUN_SUCCESS(1 validated, the follow-up update skipped: it builds on the new ad group)DRY_RUN_SUCCESSDRY_RUN_SUCCESSDRY_RUN_SUCCESS(1 validated)The follow-up that switches optimized targeting off was validated on its own against an existing Demand Gen ad group (
DRY_RUN_SUCCESS).🤖 Generated with Claude Code