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. pMax is not (yet) supported.

Settings

  • SPREADSHEET_URL: The URL of the Google Sheet that contains your old and new campaign names

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: 30-09-2022 (compatible with "new Google Ads scripts experience")
//
////////////////////////////////////////////////////////////////////

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

}

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

function main() {

    const accountSelector = AdsManagerApp.accounts()
        .orderBy('Name ASC')
        .withLimit(50);

    accountSelector.executeInParallel('renameCampaigns');

}

function renameCampaigns() {

    const accountName = AdsApp.currentAccount().getName();
    const sheet = SpreadsheetApp.openByUrl(CONFIG.spreadsheet_url).getSheetByName(accountName)

    if (sheet == null || sheet.isSheetHidden() == true) {
        console.log(`No sheet found for "${accountName}"`)
    } else {
        const lastRow = sheet.getLastRow() - 1;
        const values = sheet.getSheetValues(2, 1, lastRow, 2);

        for (let i = 0; i < values.length; i++) {
            if (values[i][1] === '') {
                console.log(`"New name" value is empty. Please provide a value in the Google Sheet.`);
            } else {
                renameSearchCampaign(values[i][0], values[i][1])
                renameShoppingCampaign(values[i][0], values[i][1])
                renameVideoCampaign(values[i][0], values[i][1])
            }
        }

        console.log(`Renamed campaigns for "${accountName}"`)
    }
}

function renameSearchCampaign(oldName, newName) {
    const campaignSelector = AdsApp
        .campaigns()
        .withCondition(`campaign.name = "${oldName}"`)
        .get();
    while (campaignSelector.hasNext()) {
        const campaign = campaignSelector.next();
        campaign.setName(newName);
    }
}

function renameShoppingCampaign(oldName, newName) {
    const campaignSelector = AdsApp
        .shoppingCampaigns()
        .withCondition(`campaign.name = "${oldName}"`)
        .get();
    while (campaignSelector.hasNext()) {
        const campaign = campaignSelector.next();
        campaign.setName(newName);
    }
}

function renameVideoCampaign(oldName, newName) {
    const campaignSelector = AdsApp
        .videoCampaigns()
        .withCondition(`campaign.name = "${oldName}"`)
        .get();
    while (campaignSelector.hasNext()) {
        const campaign = campaignSelector.next();
        campaign.setName(newName);
    }
}
Show whole script!
Loading Comments
The Experts
Tibbe van Asten Team Lead Performance Marketing
Nils Rooijmans Water Cooler Topics
Martijn Kraan Freelance PPC Specialist
Bas Baudoin Teamlead SEA @ Happy Leads
Jermaya Leijen Digital Marketing Strategist
Krzysztof Bycina PPC Specialist from Poland
How about you? JOIN US!
Sharing Knowledge
Caring

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