Hi,
I am using the following script to use campaign names and ad group names in my tracking template. The tutorial I found was replacing spaces with underscores but I am wondering if I can keep the spaces. The preview of this script seems to imply that Google sends over the campaign names and ad group names with the spaces encoded.
Script
function main(){
let adGroups = AdsApp.adGroups().withCondition("CampaignStatus = ENABLED").get();
while (adGroups.hasNext()) {
let adGroup = adGroups.next();
let group=adGroup.getName().replace(/\s/g,'%20');
let campaign=adGroup.getCampaign().getName().replace(/\s/g,'%20');
adGroup.urls().setCustomParameters({adgroup: group, campaign: campaign});
}
}
Preview
Ad group custom parameters changed from {_adgroup}=adgroup%20name, {_campaign}=US%20|%20Search%20|%20Desktop%20|%20Ecampaign to {_adgroup}=adgroup%20name, {_campaign}=US%20|%20Search%20|%20Desktop%20|%20campaign