AdWords is now Google Ads. Our new name reflects the full range of advertising options we offer across Search, Display, YouTube, and more. Learn more

Ads
2.4K members online now
2.4K members online now
Improve your Google Ads performance and boost your ROI, CTR, and Quality Score
Guide Me
star_border
Reply

CONTAINS not working for adgroup name

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

Is it not possible to use CONTAINS for "AdWordsApp.adGroups()"?

 

This works perfect:

 

var adGroupIterator = AdWordsApp.adGroups()
.withCondition('Name = "TestGroup_123"')
.get();

While this hit's randomly and don't pick up the adgroups mentioned above.

var adGroupIterator = AdWordsApp.adGroups()
.withCondition('Name CONTAINS "TestGroup_"')
.get();
1 Expert replyverified_user

Re: CONTAINS not working for adgroup name

Top Contributor
# 2
Top Contributor

Hi @Jennifer D what you show in your code should work.  CONTAINS is an acceptable operator for the AdGroup selector; I've just run my own test and it seemed to work fine.

 

I know you've probably checked a million times, but make sure what you're asking for as a match actually has matches.  Look out especially for capitalisation, spaces in the name and so on.  A good test would be to remove this single condition and log the results by name, then look for a particular group and re-instate the condition using that as the match.  

 

Where are you testing the results?  Is it possible the script is failing elsewhere in the code?

 

I tested with this:

 

function main() {
  var groups = AdWordsApp.adGroups() 
  .withCondition("Name CONTAINS 'Adwords'")
  .get();
  
  while(groups.hasNext()) {
    var thisGroup = groups.next();
    Logger.log(thisGroup.getName());
  }
}

 

And it worked just fine.

 

Jon

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