I created a script that switches all broad match keywords and malformed modified broad match keywords into proper modified broad match keywords:
https://gist.github.com/alewolf/e6fcecfba548c765a4ad52d46abcd81e
There is one issue though. I can't find a way to avoid building new keywords if a correct one already exists. Fortunately the original keyword doesn't get overwritten. But when I try to apply a label in a subsequent function I get errors.
Example:
We have an old keyword '+example' with a label applied from an earlier run.
We process a malformed keyword '++example' which results in the same as the old one '+example'. Unfortunately I can't omit building '+example' again because the old one is not part of my selection. For performance reasons I've excluded all old keywords that already have been processed, so I don't have an array to check against.
Interestingly nothing happens when i build the new keyword '+example' again. No error. And the old keyword '+example' doesn't get overwritten (which is good, we don't lose stats).
But when my function then tries to apply the label to the newly created keyword I get an error, as the script reports that the label already exists for that keyword.
The only solution I could think of to work around this is the following, but it seems very inefficient.
Each time I clean a new keyword I run a keywordSelector to find out if that new keyword already exists in the same ad group.
var keywordSelector = AdWordsApp
.keywords()
.withCondition("Text = '+example'");
var keywordIterator = keywordSelector.get();
if (keywordIterator.hasNext()) {
// we now know that this keyword already exists and act accordingly
}
When we know that the keyword already exists, we abort and continue with the next one.
Again, this feels very inefficient when we have several hundred new keywords to process. Is there a better way?