'Illegal characters in string' when updating custom parameters

160 views
Skip to first unread message

Matthew Debondt

unread,
Apr 26, 2023, 4:41:45 AM4/26/23
to Google Ads Scripts Forum
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 

Google Ads Scripts Forum

unread,
Apr 26, 2023, 8:39:00 AM4/26/23
to Google Ads Scripts Forum
Reposting the last inquiry (https://groups.google.com/g/adwords-scripts/c/uVVNmsHUCh4) from the forum as it wasn't routed to our support queue.

Regards,
Google Ads Scripts Team

Google Ads Scripts Forum

unread,
Apr 26, 2023, 8:41:55 AM4/26/23
to Google Ads Scripts Forum
Hi Matt,

Thank you for reaching out to the Google Ads Scripts Forum Channel.

Would you be so kind as to provide the following information so we're able to further investigate your concern and assist you?:
  • Google Ads account ID or CID
  • Name of the script
  • Screenshots showing the error
Best regards,
Google Ads Scripts Team
Reply all
Reply to author
Forward
0 new messages