Repository navigation
Demand Gen audiences: custom segments, lookalike lists, audiences - #148
Merged
Merged
Conversation
draft_custom_segment creates a CustomAudience from URL and keyword members (CustomAudienceService; AUTO or SEARCH, as Google refuses INTEREST and PURCHASE_INTENT on new segments). draft_lookalike_list creates a UserList with lookalike_user_list from seed lists read from the account. draft_demand_gen_audience creates an Audience whose segments share one dimension (a person in any of them is in it) and, with ad_group_id, attaches it to a Demand Gen ad group in the same mutate through a temporary resource name. The draft refuses ad groups outside Demand Gen, without use_audience_grouped, or with an audience already attached (Google: ONE_AUDIENCE_ALLOWED_PER_AD_GROUP). 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>
kLOsk
added a commit
to palermomarco/adloop
that referenced
this pull request
Dec 1, 2026
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
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.
Fourth of the four PRs agreed in #142. Independent of the others in code; it attaches audiences to the Demand Gen ad groups that #147 creates.
What
Three draft tools in a new module
ads/audience_create.py, each with its own operation, dispatch entry and apply:draft_custom_segment(create_custom_segment): aCustomAudiencewith URL and keyword members.CustomAudienceis not part ofGoogleAdsService.Mutatein v25, so the apply usesCustomAudienceService.MutateCustomAudiences.segment_typeis AUTO (default) or SEARCH; INTEREST and PURCHASE_INTENT are refused, because Google rejects them on new segments. URLs get a scheme when missing; URL length, keyword length (10 words, 80 characters), duplicates and the name's uniqueness are checked.draft_lookalike_list(create_lookalike_list): aUserListwithlookalike_user_list(seed_user_list_ids,expansion_levelNARROW / BALANCED / BROAD,country_codes). Seeds are read from the account: unknown ids are refused; closed seeds, seeds below 100 people together, and missing countries are warned. The preview says lookalikes only work in Demand Gen and cannot be edited later.draft_demand_gen_audience(create_demand_gen_audience), renamed fromdraft_audienceas you suggested: anAudience(scope CUSTOMER) with all custom segments and user lists in oneAudienceSegmentDimension, where a person in any segment is in the audience. Withad_group_id, the sameGoogleAdsService.Mutatealso creates theAdGroupCriterion.audiencethat attaches it, referring to the new audience by its temporary resource name. The draft refuses an ad group that is not in a Demand Gen campaign, one created withoutaudience_setting.use_audience_grouped(immutable), and one that already has an audience: Google allows one (ONE_AUDIENCE_ALLOWED_PER_AD_GROUP, found with validate-only).Rules updated in
.cursor/rules/adloop.mdc(three rows, and the audience pattern no longer says creating audiences is unsupported), synced. One approval card line for lookalikes (filled over one to two days, not editable).Tests
tests/test_audience_create.py: validation for each tool (names, members, segment types, unknown seeds and ids, small and closed seeds, ad group checks including the one-audience rule, blocked operations) and each apply building the right protos; the custom segment and audience applies also run throughValidateOnlyClient.uv run pytest: 2634 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)DRY_RUN_SUCCESS(1 validated)DRY_RUN_SUCCESS(1 validated)ONE_AUDIENCE_ALLOWED_PER_AD_GROUPbefore the check)Not covered live: attaching to an ad group without an audience, because every Demand Gen ad group in the account already had one. The audience part of that mutate validates on its own; the temporary resource name for
Audienceinside one mutate is the assumption left.🤖 Generated with Claude Code