So I put together the following script that you can use to automatically create a label-based countdown for elements that you want to ignore in your scripts. Each time you add new elements to your account, you can apply a label to it using the format LABEL_PREFIX_
In the scripts that you want to ignore new elements, add the following function to the bottom of the script (before the last curly brace):
function _build_label_list() { //Build a list of labels to exclude in your .withCondition() var LABEL_PREFIX = 'days_left_'; var label_iter = AdWordsApp.labels().withCondition("Name STARTS_WITH '"+LABEL_PREFIX+"'").get(); var label_array = []; while(label_iter.hasNext()) { label_array.push(label_iter.next().getName()); } return "'"+label_array.join("','")+"'" }
And then add the following
.withCondition("LabelNames CONTAINS_NONE ["+_build_label_list()+"]")to any iterators you have in your other scripts. Good luck, and if you have any questions, feel free to ask.
Thanks,
Russ
//----------------------------------- // Label Countdown // Created By: Russ Savage // FreeAdWordsScripts.com //----------------------------------- function main() { var LABEL_PREFIX = "days_left_"; // you can change this if you want // First lets build a list of labels to work with var label_iter = AdWordsApp.labels().withCondition("Name STARTS_WITH '"+LABEL_PREFIX+"'").get(); var labels_array = []; while(label_iter.hasNext()) { labels_array.push(label_iter.next().getName()); } if(labels_array.length > 0) { var labels_str = "['" + labels_array.join("','") + "']"; // grab all the keywords with the labels we want to countdown var kw_iter = AdWordsApp.keywords().withCondition("LabelNames CONTAINS_ANY "+labels_str).get(); while(kw_iter.hasNext()) { var kw = kw_iter.next(); var l_iter = kw.labels().withCondition("Name STARTS_WITH '"+LABEL_PREFIX+"'").get(); var label = l_iter.next(); // lazy here because we know this keyword has a label var days_left = parseInt(label.getName().substr(LABEL_PREFIX.length)) - 1; kw.removeLabel(label.getName()); if(days_left != 0) { var new_label_name = LABEL_PREFIX+days_left; // Create a new label if it doesn't exist if(labels_array.indexOf(new_label_name) == -1) { AdWordsApp.createLabel(new_label_name); labels_array.push(new_label_name); } kw.applyLabel(new_label_name); } } } }
I would use some of this new element at my blog https://persuasivepapers.com/
ReplyDeletelove this. the labeling script works, but the _build_label_list() and condition part arent working
ReplyDeletenvmd :) works.
DeleteI was able to find good info from your articles.
ReplyDeleteدانلود سریال قورباغه دانلود سریال قورباغه دانلود سریال قورباغه دانلود سریال قورباغه دانلود سریال قورباغه
Great article!
ReplyDeleteدانلود کتاب صوتی قدرت عادت
دانلود کتاب صوتی قدرت عادت دانلود کتاب صوتی قدرت عادت