Hello
When I try to update the custom parameters (campaign & adgroup) on ad group level with the script below, I keep receiving the error for
illegal characters in the strings. They don't contain any whitespace or special characters like ö,ü,ä anymore. I can see that the code is working as intended from the changes log - emptying the cp's first and then inserting the updated campaign and ad group names.
Thanks for your comments.
Matt
-
function main() {
var adGroupIterator = AdsApp.adGroups()
.withCondition("CampaignStatus = ENABLED")
.get();
while (adGroupIterator.hasNext()) {
var adGroup = adGroupIterator.next();
var urls = adGroup.urls();
urls.setCustomParameters({adgroup_name: " ", campaign_name: " "}); // empty the existing custom URLs
var gn = adGroup.getName().replace(/\s/g,'_').replace(/[ö]/g,'oe').replace(/[ü]/g,'ue').replace(/[ä]/g,'ae').replace(/^[\r\n]+|\.|[\r\n]+$/g, "");
Logger.log("Ad group name gn variable: " + gn);
var cn=adGroup.getCampaign().getName().replace(/\s/g,'_').replace(/[ö]/g,'oe').replace(/[ü]/g,'ue').replace(/[ä]/g,'ae').replace(/^[\r\n]+|\.|[\r\n]+$/g, "");
Logger.log("campaign cn variable: " + cn);
urls.setCustomParameters({adgroup_name: gn, campaign_name: cn}); // Set new custom parameters
}
}
Viessmann Group: www.viessmann.family
Newsroom: www.viessmann.family/newsroom

Viessmann Climate Solutions Berlin GmbH
Friedrichstraße 148, 10117 Berlin
GeschäftsführerInnen: Frauke von Polier, Laura Hümbs, Thomas Heim
Sitz der Gesellschaft: Allendorf (Eder)
Registergericht: AG Marburg (Lahn) - HRB 6806 - USt-IdNr. DE308516904