Automatically syncs each campaign's name into a Google Ads custom parameter (e.g. {_campaignname}) so that downstream UTM tracking always reflects the current campaign name even after renames. Optionally appends the full UTM string to each campaign's final URL suffix.
by Google Marketing Solutions·github.com/google-marketing-solutions/campaign_utm_custom_parameter
Google Ads' built-in {campaignid} and {campaignname} ValueTrack parameters expose the ID, but the campaign name in URL suffixes goes stale when campaigns are renamed. This script writes the live campaign name into a custom parameter on every Search, Shopping, and Performance Max campaign, keeping your utm_campaign values accurate in GA4 and other analytics tools. Runs against the single account or — if installed at MCC level — every sub-account in the manager.
| Variable | Default |
|---|---|
CAMPAIGN_NAME_CUSTOM_PARAMETER | 'campaignname' |
ADD_TO_CAMPAIGN_FINAL_URL_SUFFIX | false |
Processing Account "Acme Retail — US" Processing Account "Acme Retail — EU" Campaign name missing for campaign ID 1234567890
Auto-detects MCC vs single account via AdsManagerApp and iterates all sub-accounts when run at MCC level. Campaign names are sanitized: anything outside [a-zA-Z0-9|;_/^(!] is replaced with _, and names are truncated to 250 chars (custom-parameter limit). Only touches Search, Shopping, and Performance Max campaigns — Display, Video, Demand Gen, App, and Hotel campaigns are skipped.