Removing the broad match modifier using a script

Google has released an update that removes the broad match modifier.

Now its functionality will replace the phrase match —

It is clear that Google has made some kind of “reverse support” for this situation, but it’s better to get away from the old format sooner rather than later. Start accumulating statistics in phrase matching, avoid duplication, etc. and so on.

I wrote a simple script for this:

function main() {
    // select non-deleted campaigns
    var campaignSelector = AdsApp
        .withCondition('Status != REMOVED')
        .orderBy('Impressions DESC')
    var campaignIterator = campaignSelector.get();
    while (campaignIterator.hasNext()) {
        var campaign =;
        // select non-remote groups in them
        var adGroupSelector = campaign
            .withCondition('Status != REMOVED')
            .orderBy('Impressions DESC')
        var adGroupIterator = adGroupSelector.get();
        while (adGroupIterator.hasNext()) {
            var adGroup =;
            Logger.log(campaign.getName() + ' - ' + adGroup.getName());
            // select non-deleted phrases in them, in broad match, with a modifier
            var keywordSelector = adGroup
                .withCondition('KeywordMatchType = BROAD')
                .withCondition('Text CONTAINS_IGNORE_CASE "+"')
                .withCondition('Status != REMOVED')
                .orderBy('Impressions DESC')
            var keywordIterator = keywordSelector.get();
            while (keywordIterator.hasNext()) {
                var keyword =;
                var key_text = keyword.getText().replace(/\+/gmi, '');
                // create a new key in phrase match
                var newKeyResult = adGroup.newKeywordBuilder()
                    .withText('"' + key_text + '"')
                // and delete the old key
                if (newKeyResult.isSuccessful()) {