Repository navigation
draft_campaign / update_campaign: campaign URL options - #116
Conversation
kLOsk
left a comment
There was a problem hiding this comment.
Looks good. One fix before we merge: the {lpurl} check refuses {escapedlpurl+2} and {escapedlpurl+3}, which are valid ValueTrack parameters. Something like \{(un)?(escaped)?lpurl(\+[23])?\}, also used in _example_click_urls. Please also note in the tool description that example_click is approximate (ad group, ad or keyword templates override the campaign's), and say "alphanumeric, max 8" for custom parameter keys. After #115 lands this needs a rebase, sorry about the shared hunks.
Optional tracking_url_template, final_url_suffix and url_custom_parameters on both tools. Omitted leaves a value unchanged; an empty string or list clears it, and the preview names the removal. Validation stays light: {lpurl} or any variant ({lpurl+2}, {escapedlpurl+3}, ...) in the template, alphanumeric custom parameter keys of at most 8 characters, values up to 250; the validate_only dry run catches the rest. The update_campaign preview shows each current value and example_click, one of the campaign's final URLs with the campaign's options applied (approximate: lower-level templates override it).
Fixes kLOsk#105.
|
Rebased on
|
10f0d06 to
ebde590
Compare
|
Thanks for merging, and for the README update. #117 is rebased on top of it. |
Closes #105.
Adds optional
tracking_url_template,final_url_suffixandurl_custom_parameterstodraft_campaignandupdate_campaign, in the shape agreed on the issue. It's separate from #115 (location option), as you asked. The two touch the same functions, so whichever merges second needs a small rebase, and I'll do it.Semantics
update_campaigndraft_campaignNone)""/[]url_custom_parametersreplaces the whole listExisting callers send exactly the same request as before, and a test pins that.
Validation
As you asked, it's kept light:
{lpurl},{lpurl+2},{lpurl+3},{unescapedlpurl}or{escapedlpurl}. Case-insensitive._on a key is dropped, because{_grp}in a template means keygrpand people type the underscore.?or&is stripped.Everything else is left to the
validate_onlydry run.Preview (
update_campaign)changesholdscurrent_<field>next to the new value, likecurrent_daily_budget.Removes the campaign's tracking_url_template (currently '…'). Clearing something already empty doesn't.example_click:landing_page_url(with the suffix) andtracking_url(the template with{lpurl}and{_key}filled in).{keyword}are left as they are.{lpurl}is shown as the bare final URL, because Google escapes it by position. The docstring says it's approximate; its job is to make a typo visible.draft_campaignhas no ads either, so it has no example.Apply and dry run
update_maskpath, so an empty value under the mask clears it.validate_onlypath.I ran validate-only dry runs against a paused Search campaign in a live account:
{adgroupid}and{keyword};Both came back
DRY_RUN_SUCCESSwithvalidated_calls: 1, and nothing was applied. The preview'sexample_clickshowed the expected URL.Rules and tests
.cursor/rules/adloop.mdcnow has the tool table entries and one bullet on the semantics andexample_click. Synced withscripts/sync-rules.py.tests/test_campaign_url_options.py(20 tests) covers:{lpurl}variant, a template without one, the key and value limits, and an invalid input refused before any read;example_click, removals and the no-ads case;uv run pytestgives 1683 passed, 2 skipped.get_campaign_settingsreads all three back. Docs left for you to regenerate after the release.