How to rename campaigns & ad-groups. There're 50 campaigns and 430 ad groups using Scripts

335 views
Skip to first unread message

Salik Khan

unread,
Nov 3, 2015, 6:35:13 AM11/3/15
to AdWords Scripts Forum
Hi there,

We have 50 campaigns and 430 ad groups, I want to rename all of the ad groups and campaigns, if done manually, it will take a lot of time,  is there any Adwords script which I can use to do this ?

This is urgent, please help me.

Salik

Victor Kaugesaar

unread,
Nov 3, 2015, 7:18:05 AM11/3/15
to AdWords Scripts Forum
Hi Salik,

It's possible to do with scripts. But it depends on how you want to rename them. Add something to the names? replace? Anyhow the function you'd want to use is .setName()

function main() {

   
var campaignIterator = AdWordsApp.campaigns().get();
   
while(campaignIterator.hasNext()) {
       
var campaign = campaignIterator.next();
       
var campaignName = 'Scripts Test | ' + campaign.getName();
        campaign
.setName(campaignName);
   
}

   
var adGroupIterator = AdWordsApp.adGroups().get();
   
while(adGroupIterator.hasNext()) {
       
var adGroup = adGroupIterator.next();
       
var adGroupName = 'test | ' + adGroup.getName();
        adGroup
.setName(adGroupName);
   
}
}

Keep in mind that above code is just to show how to use .setName() don't run the script other than in preview. Since it will rename all campaigns and ad groups.

Tyler Sidell (AdWords Scripts Team)

unread,
Nov 3, 2015, 9:52:21 AM11/3/15
to AdWords Scripts Forum
Thanks Victor for providing that Solution to Salik.

If there are any further questions please do let us know.

Cheers,
Tyler Sidell
AdWords Scripts Team

Salik Khan

unread,
Nov 3, 2015, 1:27:33 PM11/3/15
to AdWords Scripts Forum
Hi Victor,

Thank your for the reply.

I want to replace the Adgroup names, and there are more than 400 ad groups. So, do I need to run a script for every adgroup? Because each AdGroup will have a unique new name. 

Tyler Sidell (AdWords Scripts Team)

unread,
Nov 3, 2015, 3:34:20 PM11/3/15
to AdWords Scripts Forum
Hi Salik,

You would not need to run this script for each adGroup. The selector that Victor provided, var adGroupIterator = AdWordsApp.adGroups().get();, should take care of that. Victor's script adds "test |" before the original adGroup name. If you needed to do some matching and make the adGroups more unique you may want to look at using Bulk Uploads.

Thanks,

Tyler Sidell
AdWords Scripts Team

Reply all
Reply to author
Forward
0 new messages