Create Google Ads Ad Group using scripts

76 views
Skip to first unread message

Andreea Petrea

unread,
Apr 15, 2021, 8:35:47 AM4/15/21
to Google Ads Scripts Forum
Hello,

I am trying to create an Ad group using scripts but i see no changes.
I use this code:
function main() {  
 addAdGroup();
}

function addAdGroup() {
  var campaignIterator = AdsApp.campaigns()
      .withCondition('Name = "test"')
      .get();
  if (campaignIterator.hasNext()) {
      Logger.log("campaign found");

    var campaign = campaignIterator.next();
    var adGroupOperation = campaign.newAdGroupBuilder()
        .withName(response)
        .withCpc(1.2)
        .build();
      Logger.log(response);

  }
}

I tested also with campaign named "test" being enabled or paused.

Any help?

Andreea Petrea

unread,
Apr 15, 2021, 9:17:30 AM4/15/21
to Google Ads Scripts Forum

Google Ads Scripts Forum Advisor

unread,
Apr 15, 2021, 11:06:28 PM4/15/21
to adwords...@googlegroups.com
Hi Andreea,

Thanks for reaching out. Harry here, from the Google Ads Scripts Team. Glad that you have solved the issue on your end. In addition, you may check if a builder has been successful by using the AdGroupOperation's method isSuccessful. Let me know if there's anything else that I can assist you with.


Thanks, 
Google Logo
Harry Cliford Rivera
Google Ads Scripts Team
 


ref:_00D1U1174p._5004Q2FYmjr:ref
Reply all
Reply to author
Forward
0 new messages