Filter out paused campaigns and ad groups in keyword iterator

294 views
Skip to first unread message

Jason B.

unread,
Dec 11, 2012, 12:42:44 PM12/11/12
to adwords...@googlegroups.com
Can anyone please tell me how to filter out paused campaigns and ad groups while in the keyword iterator without nesting? I imagine there should be a condition to accomplish this, but if so, I can't seem to figure out what it is.

Any help is greatly appreciated and thanks in advance!

Jason B.

unread,
Dec 13, 2012, 1:45:21 PM12/13/12
to adwords...@googlegroups.com
Can I assume no replies to this question indicate it's not possible?

Tomas Kapler

unread,
Dec 13, 2012, 2:15:27 PM12/13/12
to adwords...@googlegroups.com
Maybe just noone understands why you need it without nesting when nesting is exactly the solution, so something like

var keywordsIterator = AdWordsApp.campaigns().get().next().keywords().get()
should be perfect answer

Jason B.

unread,
Dec 13, 2012, 2:40:35 PM12/13/12
to adwords...@googlegroups.com
Hi. Thanks for responding. I'm the first to admit I'm somewhat of a noob, but it just seems like it would be simpler to be able to add conditions for keywords that are active across the board instead of all the additional nesting code. For example, something like this:

var keywordIterator = AdWordsApp.keywords()
     
.withCondition("CampaignStatus = ENABLED")
      .withCondition("AdGroupStatus = ENABLED")
      .withCondition("Status = ENABLED")
     
.withCondition("Impressions > 0")
     
.forDateRange("LAST_MONTH")  
     
.get();}

where you can include conditions for both campaign and ad group statuses.

Tomas Kapler

unread,
Dec 13, 2012, 2:44:26 PM12/13/12
to adwords...@googlegroups.com
Have you tried something like this:

var keywordsIterator = AdWordsApp.campaigns().withCondition("CampaignStatus = ENABLED").get().next().keywords().withCondition("Impressions > 0").get()
?
Tom

Jason B.

unread,
Dec 13, 2012, 3:16:26 PM12/13/12
to adwords...@googlegroups.com
Thanks!

Jason B.

unread,
Dec 14, 2012, 9:30:28 AM12/14/12
to adwords...@googlegroups.com
Unfortunately this didn't work when I tried to run it. I got a "Value ENABLED is invalid" error, which I assume indicates the field, CampaignStatus, is invalid. Do you know if it's just incorrect syntax or if "CampaignStatus" and "AdGroupStatus" simply don't exist as valid fields?

Alpha

unread,
Dec 14, 2012, 11:33:53 AM12/14/12
to adwords...@googlegroups.com

Yeah, they don't exist.  I never realized how many "active" keywords I had in deleted adgroups until Adwords scripts.  :)

Kevin Winter (AdWords Scripts Team)

unread,
Dec 14, 2012, 4:20:25 PM12/14/12
to adwords...@googlegroups.com
Just a heads up, the selectors documentation includes a table of fields that are allowed in the withCondition clause (campaigns, keywords).

- Kevin Winter
AdWords Scripts Team

Tomas Kapler

unread,
Dec 14, 2012, 4:38:39 PM12/14/12
to adwords...@googlegroups.com
Sorry Jason, i have made a mistake as i have reused your script and didn't look into the proper atributes. I just wanted to point out, that if you from some reason want to have it in one line, you can with syntax i have written, so e.g. this

var keywordsIterator = AdWordsApp.campaigns().withCondition("Status = ENABLED").get().next().keywords().withCondition("QualityScore >= 6").get()


should give you iterator over all keywords with quality score 6 and higher from Enabled Campaigns only.


Or you can do at the beggining of your function something like


var myCampaigns = AdWordsApp.campaigns().withCondition("Status = ENABLED").get().next()

and then if you need adGroups or Keywords just from Enabled campaigns, you will do e.g.

var keywordsIterator = myCampaigns.keywords().withCondition("QualityScore >= 6").get()


(i home i am right, you must try it ;)

Reply all
Reply to author
Forward
0 new messages