Skip to content

Geo exclusions and ad schedule on draft_campaign and update_campaign - #121

Open
illia-sapryga wants to merge 1 commit into
kLOsk:mainfrom
illia-sapryga:feat/campaign-geo-exclude-schedule
Open

illia-sapryga wants to merge 1 commit into
kLOsk:mainfrom
illia-sapryga:feat/campaign-geo-exclude-schedule

Conversation

@illia-sapryga

Copy link
Copy Markdown
Contributor

Today a new campaign needs follow-up plans for its exclusions and its schedule: add_negative_locations and add_ad_schedule, each previewed and applied after the campaign exists. There is also no way to say "this is the complete list" on an existing campaign. You have to work out the difference yourself and go through remove_entity one criterion at a time.

This adds geo_exclude_ids and ad_schedule to both tools, as parameters rather than new tools.

On draft_campaign they go in the campaign's atomic mutate, so a failure leaves nothing behind.

On update_campaign they replace the whole list: omitted leaves it, [] clears it. The preview shows current_geo_exclude_ids and current_ad_schedule, and apply re-reads them and refuses if they moved after the preview. Only the entries that differ are removed or added, so a window or exclusion that stays keeps its criterion and history. Exclusion removals go before the positive geo operations and exclusion creates after them, so a location can move between the two lists in one request.

Windows go through _validate_schedule, so the rules are the ones add_ad_schedule has. Double confirmation:

  • a first schedule, using add_ad_schedule's logic and warning text (now a shared helper)
  • clearing a schedule, because the campaign serves at all hours again
  • dropping a geo exclusion, because the campaign can serve there again

One thing you may want to decide: I also ask for the double confirmation when draft_campaign sets a schedule, so the first-schedule rule is the same everywhere. The campaign is new and PAUSED, so nothing is being switched off, and the dialog says "cannot be undone". If you'd rather have only the warning there, it's one line.

When geo_exclude_ids is passed next to geo_target_ids, the "negative exclusions will be preserved" warning no longer appears, since they are being replaced. A list with a blank entry is refused, so [" "] can't quietly clear the exclusions. Passing the values a campaign already has comes back as nothing to change.

What it does not do: add_negative_locations and add_ad_schedule stay as they are, for adding to what's there. An exclusion that overlaps geo_target_ids in the same call is refused, but an overlap with the campaign's existing positive targets is left to Google's answer in the dry run.

Tested with the full suite plus tests/test_campaign_geo_exclude_schedule.py. Plans run through confirm_and_apply(dry_run=True) with real protos and the real validate-only wrapper, and fake services that only record the request. GAQL reads are stubbed. I have not run this code against a live account, so Google's answer to the replacement requests is untested, including the removal order.

draft_campaign puts them in the campaign's atomic mutate. update_campaign
replaces the whole list: omitted leaves it, [] clears it. The preview shows the
current values and apply refuses if they changed after it; only the entries
that differ are removed or added.

Windows use add_ad_schedule's validation. A first schedule and clearing a
schedule need a double confirmation, as does dropping a geo exclusion.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant