Rename campaigns in bulk

Change campaign names simultaneously in multiple Google Ads accounts

Start Now!
Rename Get started!

Want to change a lot of campaign names in multiple Google Ads accounts across a MCC? This script can help you out! Just fill in the old and new campaign names in a Google Sheet and run the script. Read on to find out more.

Difficulty


Tags

Why this script?

If you want to change your Google Ads campaign names in bulk, the Google Ads Editor, unfortunately, cannot help out. The campaign name is used by the Google Ads Editor to identify campaigns and you can't upload a bulk edit without the campaign name. Furthermore, not everyone is using tooling (like Search Ads 360) which makes bulk editing of campaign names possible. Changing campaign names across multiple account is a request I've received a few times now, mainly because of the roll-out of naming conventions. So let's check how this script works!

How to setup this script?

Setting up this script is pretty straightforward. Just follow these steps and your up and running in no-time:

  1. Grab a copy of this Google Sheet
  2. Create a tab/sheet per account you want to edit. Make sure the sheet name exactly matches the account name (including capitals)
  3. Put the current campaign name in the first column and the new campaign name in the second column. The header row (first row) is ignored by the script
  4. Hide tabs you're not using (e.g. work in progress). They will be skipped
  5. Always preview the script to make sure everything works as expected
  6. Finally, run the script 

A few things the script cannot do

Make sure you don't use single quotes in your campaign names (e.g. A'dam). This script does edit Search, Shopping, Display and Video campaigns. However, other exotic campaign types like Discovery or Universal App campaigns are not yet supported by Google Ads scripts.

Settings

  • SPREADSHEET_URL: The URL of the Google Sheet that contains your old and new campaign names
  • ACCOUNT_IDS or LABEL_NAME: Choose if you want to select accounts by Account ID or by applying a label. Leave empty to process all the accounts in the MCC

Scheduling: No need to schedule this script. Just run it once to change the campaign names. 

The script
// Bulk rename Campaign names (MCC)
//
// ABOUT THE SCRIPT
// Rename campaigns in Bulk on MCC level
//
// Created By: Martijn Kraan
// Brightstep.nl
// 
// Created: 28-12-2019
// Last update: 28-12-2019
//
////////////////////////////////////////////////////////////////////

var config = {

    // This is the part where you configure the script

    SPREADSHEET_URL: 'https://docs.google.com/YOUR-SPREADSHEET-URL-HERE',
    // The URL of the Google Sheet that contains your old and new campaign names
    // Grab a copy of the template here: https://docs.google.com/spreadsheets/d/1uwjQBkyhdsGtLhMseShsOa7_lx1UoPq4V1sWGV5V53c/copy

    ACCOUNT_IDS: [],
    LABEL_NAME: '',
    // Pick you preferred method of selecting accounts. Leave empty to process all the accounts in the MCC
    // Fill in the account ID's or apply a label to the account(s) you want to check
    // E.g. ACCOUNT_IDS: ['123-456-7891', '987-654-3211'] or leave empty by using []
    // E.g. LABEL_NAME: 'script: Bulk Rename Campaigns' or leave empty by using ''  

}

////////////////////////////////////////////////////////////////////

function main() {

    var accountSelector;

    if (config.ACCOUNT_IDS.length != 0) {
        accountSelector = AdsManagerApp.accounts()
          .withIds(config.ACCOUNT_IDS)
          .orderBy('Name ASC')
          .withLimit(50);
      
    } else if (config.LABEL_NAME) {
        accountSelector = AdsManagerApp.accounts()
          .withCondition('LabelNames CONTAINS "' + config.LABEL_NAME + '"')
          .orderBy('Name ASC')
          .withLimit(50);
      
    } else {
        accountSelector = AdsManagerApp.accounts()
          .orderBy('Name ASC')
          .withLimit(50)
    }

    accountSelector.executeInParallel('renameCampaigns');

}

function renameCampaigns() {

    var accountName = AdWordsApp.currentAccount().getName();
    var sheet = SpreadsheetApp.openByUrl(config.SPREADSHEET_URL).getSheetByName(accountName)

    if (sheet == null || sheet.isSheetHidden() == true) {
        Logger.log('No sheet found for "' + accountName + '"')
    } else {
        var lastRow = sheet.getLastRow() - 1;
        var values = sheet.getSheetValues(2, 1, lastRow, 2);
      
        for (i = 0; i < values.length; i++) {
            renameSearchCampaign(values[i][0], values[i][1])
            renameShoppingCampaign(values[i][0], values[i][1])
            renameVideoCampaign(values[i][0], values[i][1])
        }
      
        Logger.log('Renamed campaigns for "' + accountName + '"')
    }
}

function renameSearchCampaign(oldName, newName) {
    var campaignSelector = AdWordsApp
        .campaigns()
        .withCondition("Name = '" + oldName + "'")
        .get();
    while (campaignSelector.hasNext()) {
        var campaign = campaignSelector.next();
        campaign.setName(newName);
    }
}

function renameShoppingCampaign(oldName, newName) {
    var campaignSelector = AdWordsApp
        .shoppingCampaigns()
        .withCondition("Name = '" + oldName + "'")
        .get();
    while (campaignSelector.hasNext()) {
        var campaign = campaignSelector.next();
        campaign.setName(newName);
    }
}

function renameVideoCampaign(oldName, newName) {
    var campaignSelector = AdWordsApp
        .videoCampaigns()
        .withCondition("Name = '" + oldName + "'")
        .get();
    while (campaignSelector.hasNext()) {
        var campaign = campaignSelector.next();
        campaign.setName(newName);
    }
}
Show whole script!
The Experts
Tibbe van Asten Head of PPC @ Increase
Nils Rooijmans Water Cooler Topics
Martijn Kraan Freelance PPC Specialist
Bas Baudoin Teamlead SEA @ Happy Leads
How about you? JOIN US!
Sharing Knowledge
Caring

Sharing Knowledge

Adsscripts.com is all about sharing knowledge. In the current market, PPC specialists like to keep their knowledge and experience to themselves. We're convinced that sharing knowledge can ensure that everyone gets better at their work. We want to change this by sharing our knowledge about scripts with everyone.

Do you also want to contribute? We are open to new ideas and feedback on everything you find on Adsscripts.com.

Contact us

Training &
Workshop
Contact us!
Adsscripts Training & Workshop