Youtube Ads Google Ads Scripts Dynamic Custom Parameter Not Working

168 views
Skip to first unread message

Alrisa Lee

unread,
Jul 11, 2022, 3:25:30 PM7/11/22
to Google Ads Scripts Forum
Hi

Im trying to run Google Ads Script to dynamically ad utm or custom paramaters to all our Google Ads campaigns but I show it only returns preview or result on Search & Display campaign? Not on our Youtube campaigns. Is there a way to fix this?

This is what my script looks like:

function main() {
var adGroupIterator =
AdsApp.adGroups().get();
while (adGroupIterator.hasNext()) {
var adGroup = adGroupIterator.next();
var gn=adGroup.getName().replace(/\s/g,'_');
var cn=adGroup.getCampaign().getName().replace(/\s/g,'_');
adGroup.urls().setCustomParameters({adgroup: gn, campaign: cn});
}
}

Google Ads Scripts Forum Advisor

unread,
Jul 12, 2022, 2:07:54 AM7/12/22
to adwords...@googlegroups.com

Hello Alrisa,

I’m James from the Google Ads scripts support team. Thank you for raising your concern to us.

Based on the given script, I observed that you’re using a regular AdGroupSelectorTake note that the getCampaign method of a regular AdGroupSelector only returns search and display campaigns. Since you’re looking for your youtube / video campaigns, I recommend that you use VideoAdGroupSelector along with the getVideoCampaign method instead.

Let me know if you have any questions.

Regards,

Google Logo
James Howell
Google Ads Scripts Team
 


ref:_00D1U1174p._5004Q2cUvWN:ref

Maria Shemetova

unread,
Nov 3, 2023, 10:53:59 AM11/3/23
to Google Ads Scripts Forum
Hi

If I change the script the next way:

function main() {
  let videoAdGroupIterator = AdsApp.videoAdGroups().withCondition("CampaignStatus = ENABLED").get();
  while (videoAdGroupIterator.hasNext()){
    let adGroup = videoAdGroupIterator.next();
    let adgroup_name = adGroup.getName().replace(/\s/g,'_');
    adGroup.urls().setCustomParameters({adgroup: adgroup_name});
  }
}

It still doesn't work, with the error: adGroup.urls is not a function Could you please advise how to fix it? Thanks!
Reply all
Reply to author
Forward
0 new messages