Hi,
Can you please advise on how I can map how many ads and keywords I have in my adGroups in a faster way than the code below?
The approach I tried is working, but it seems that it is too demanding i.e. it is super-slow, so in effect not useful.
It would be great if I could somehow use AdsApp.search() instead at least partially, as it is much faster. But I cannot figure out how that can be done since I'm starting from the adGroups and then look at their content, rather than the other way around.
Here's a code snippet to illustrate a case where I wish to do smth when there is not 5 ads and/or 1 keyword in an adGroup
var adGroupIter = AdsApp.adGroups()
.withCondition('campaign.status = ENABLED')
.withCondition('ad_group.status = ENABLED')
.withCondition('campaign.name REGEXP_MATCH ".*some campaign.*"')
.withCondition('campaign.name NOT REGEXP_MATCH ".*some other campaign.*"')
.get();
while (adGroupIter.hasNext()) {
var adGroup = adGroupIter.next();
var ads = adGroup.ads()
.withCondition('ad_group_ad.status = ENABLED')
.withCondition('ad_group_ad.ad.type = EXPANDED_TEXT_AD')
.get();
if (ads.totalNumEntities() != 5) {
console.log(adGroup.getCampaign().getName()+' > '+adGroup.getName()+' has '+ads.totalNumEntities()+' active ads');
}
var keywords = adGroup.keywords()
.withCondition('ad_group_criterion.status = ENABLED')
.get();
if (keywords.totalNumEntities() != 1) {
console.log('*'+adGroup.getCampaign().getName()+' > '+adGroup.getName()+' has '+keywords.totalNumEntities()+' active keywords');
}
}
Hope you can point my in the direction of a better solution
Thanks
Sigurd