1.8K members online now
1.8K members online now
Dive into advanced features like Remarketing, Flexible Bid Strategies, AdWords Editor, and AdWords Scripts
Guide Me

AdWords Script to add Label to newly created ads

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

Hi everyone,

I'm looking for a script that can add labels into ads that were recently put into the account under specific campaigns that are already labeled up.


So in I have 3 campaigns:

Campaign 1

Campaign 2

Campaign 3


And Campaign 3 is the one that is labelled with "Label 1" for example, I would only like the recently added ads within Campaign 3 to be labelled up.


Would anyone be able to help with this as I've tried a few varieties right now but cannot get a working solution.


Many thanks,



2 Expert replyverified_user

Re: AdWords Script to add Label to newly created ads

Top Contributor
# 2
Top Contributor

Re: AdWords Script to add Label to newly created ads

Top Contributor
# 3
Top Contributor

Hi @Lisa F, what do you want to Label the Ads with?  I use a date labelling script in all my client Accounts that applies a Label containing today's date to any unlabelled elements (therefore acting as a date of creation Label), would it be something like that?


What exact problems are you having?  One of the keys to getting Labelling right in scripts is being able to choose the elements that aren't already labelled and there's a couple of ways you can approach that.  The first is simply ask AdWords for Ads that don't have specific, known, Labels, e.g.

var adIter ="LabelNames CONTAINS_NONE ['MyLabel','MyLabel2']").get();

If you don't know what the Label names might be (for example, if they're dynamically generated by another script), it's a good idea to ensure these Labels have a common string to identify them.  For example, my date Labeller labels all begin "dadd: " so I can build a list of Labels to exclude using:

var labelIter = AdWordsApp.labels().withCondition("Name CONTAINS 'dadd'").get();
var allDateLabels = "['";
while (labelIter.hasNext()) {
  var thisLabelName =;
  allDateLabels += "'" + thisLabelName + "',";
allDateLabels = allDateLabels.substr(0,allDateLabels.length - 1) + "]";

You can then drop "allDateLabels" (or whatever you call it) into the first example as follows:

var adIter ="LabelNames CONTAINS_NONE " + allDateLabels).get();

Hope this helps!


AdWords Top Contributor Google+ Profile | Partner Profile | AdWords Audits