Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

95
Visualizações
Returning Google ads within ad groups with specific labels

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);
    }

}
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda