Hi everyone!
I really need your help to customize a script.
I've been using a poplular script to remove 1 label for the optimization process and it works perfectly. The problem is now I have 12 labels and I want one script to remove all of them.
My labels are ['ROI -100', 'ROI -20-0', 'ROI -75-50', 'ROI -99-75', 'ROI 0-50', 'ROI 200-300', 'ROI 300-400', 'ROI 400-600', 'ROI 600-800', 'ROI 800-1000', 'ROI-50-20', 'ROI 0-50'].
The perfect script would remove all labels that contain word 'ROI'.
The script I'm using:
function main() {
var DEL_LABEL = 'ROI 0-50';
var keywordIterator = AdsApp.keywords()
.withCondition("LabelNames CONTAINS_ANY ['ROI 0-50']")
.get();
while (keywordIterator.hasNext()){
var keyword = keywordIterator.next()
var labelIterator = keyword.labels().get()
while (labelIterator.hasNext()){
var label = labelIterator.next()
var labelname = label.getName()
Logger.log("labelname: "+labelname)
if (labelname = DEL_LABEL) {
keyword.removeLabel(DEL_LABEL)
}
}
}
}
I would be grateful for any suggestions!