I can't seem to figure out why my code isn't returning ads with a specific labels and need help understanding where I went wrong with my code. I am iterating through the ad groups that have a specific label "AUTOENABLE" and then iterating through each ad with the same label but also checking on another script the URL endpoint.

  adCount: 0,   adsEnabled: 0,   adsDisabled: 0,   adsSetEnabled: [],   adsSetDisabled: [] }; function adsTest() {         var ag_iter = AdWordsApp.labels().withCondition("Name = AUTOENABLE").get();      if(ag_iter.totalNumEntities() < 1){     Logger.log("ERROR: No AUTOENABLE label found in AdGroup");     return;            // Iterating through all Ad groups to work individually     while (ag_iter.hasNext()) {     // Getting the ad group and printing it's name     var ag = ag_iter.next();     Logger.log(ag.getName())                   // Taking an iterator from all Ads inside Ad Group     var ad_iter = ag.ads().withCondition("LabelNames = AUTOENABLE").get();     if(ad_iter.totalNumEntities() < 1){     Logger.log("ERROR: No AUTOENABLE label found in Ads.");     return;   }     while(ad_iter.hasNext()){       var ad_iter = ads.next();       checkAd(ad);     }    }   }       report(); } function report(){     Logger.log(stats.adCount + " ads checked");     Logger.log(stats.adsEnabled + " ads are enabled");     Logger.log(stats.adsDisabled + " ads are disabled");     Logger.log((stats.adsSetDisabled.length + stats.adsSetEnabled.length) + " ads modified");     if(stats.adsSetEnabled.length > 0){       Logger.log("Changed to enabled:");       stats.adsSetEnabled.forEach(adLog);     }     if(stats.adsSetDisabled.length > 0){       Logger.log("\nChanged to disabled:");       stats.adsSetDisabled.forEach(adLog);     } } 

Tag:google-ads-api, javascript

Add a new comment.