Select sitelinks with IDs and add them to a campaign

28 views
Skip to first unread message

Jackro

unread,
Jun 20, 2022, 11:03:21 AM6/20/22
to Google Ads Scripts Forum
Hi I've been trying for a while to select 4 sitelinks from my account with IDs and then adding all of them to every campaign, this is the basic codes I came up with:

function main() {
     var campaignSelector = AdsApp
                         .campaigns()
                         .withCondition("CampaignStatus = 'ENABLED'");

  var campaignIterator = campaignSelector.get();

 
 var campaignSitelinkSelector = AdsApp
     .extensions()
     .sitelinks()
     .withIds(['xxxx' , 'xxxx' , 'xxx' , 'xxxxxxxx']);
                     
 var sitelinkIterator = campaignSitelinkSelector.get()

  while (campaignIterator.hasNext()) {

  var campaign = campaignIterator.next();
  var sitelink =  sitelinkIterator.next();
   
       
    campaign.addSitelink(sitelink)
   
}
}
}
}
}

the script simply adds one sitelink to a campaign then moves to the next campaign and add the next and so on and so forth. I want to add all the four sitelinks added to each and every campaign.

Thx in advance!

Google Ads Scripts Forum Advisor

unread,
Jun 21, 2022, 6:39:12 AM6/21/22
to adwords...@googlegroups.com

Hi Jackro,
 

Thanks for reaching out to the Google Ads Scripts.


With regard to your concern, so our team can better check this concern, could you provide the CID and the Script name? So we could have a closer look at your implementation.
 

You can provide it via Reply privately to author option. If this option is not available, then send it instead on this email address googleadsscr...@google.com


Regards,

Google Logo
Darwin
Google Ads Scripts Team
 


ref:_00D1U1174p._5004Q2byFoA:ref

Jackro

unread,
Jun 21, 2022, 7:29:43 AM6/21/22
to Google Ads Scripts Forum
Hi Darwin,

I sent you the CID and Script Name privately,

Regards

adsscripts schrieb am Dienstag, 21. Juni 2022 um 12:39:12 UTC+2:

Hi Jackro,
 

Thanks for reaching out to the Google Ads Scripts.


With regard to your concern, so our team can better check this concern, could you provide the CID and the Script name? So we could have a closer look at your implementation.
 

You can provide it via Reply privately to author option. If this option is not available, then send it instead on this email address googleadsscripts-sup...@google.com

Reply all
Reply to author
Forward
0 new messages