TypeError: Cannot find function AdGroup in object AdWordsApp. (line 6)

594 views
Skip to first unread message

aitor.uda...@gmail.com

unread,
Jun 27, 2016, 12:53:32 PM6/27/16
to AdWords Scripts Forum
function main() {
 var sheetprueba = SpreadsheetApp.openByUrl(SPREADSHEET_URL);//abrimos sheet 
 //var sheet = SpreadsheetApp.getActiveSpreadsheet();
// var keywordsIterator = AdWordsApp.keywords().get();
var adGroupIterator = AdWordsApp.AdGroup().get();/*
 var campaignIterator = AdWordsApp.campaign().get();
 var TargetedLocationIterator = AdWordsApp.TargetedLocation().get();*/
  sheetprueba.getRange("A1").setValue("Campaña");
  sheetprueba.getRange("B1").setValue("Grupo");
  sheetprueba.getRange("C1").setValue("Keyword");
  sheetprueba.getRange("D1").setValue("Localización");

  
  for (var row = 2; adGroupIterator.hasNext(); row ++) {
   // var keyword = keywordsIterator.next();
var group = adGroupIterator.next();/*
/*var campaign=campaignIterator.next();
var localizacion=TargetedLocationIterator.net();*/
    /*sheetprueba.getRange("C" + row).setValue(keyword.getText());*/
    sheetprueba.getRange("A" + row).setValue(group.getName());/*
   /* sheetprueba.getRange("B" + row).setValue(campaign.getName());
sheetprueba.getRange("D" + row).setValue(localizacion.getName());*/

  }

  Logger.log("Report ready! Visit the following URL to see it:");
  Logger.log("https://docs.google.com/spreadsheet/ccc?key=" + spreadsheet.getId());
}

Hello, I have made a script by first making him to take me the keywords and it worked but when testing if you can catch me groups gives me an error and not why

Thanks

Tyler Sidell (AdWords Scripts Team)

unread,
Jun 27, 2016, 1:11:15 PM6/27/16
to AdWords Scripts Forum
Hi,

Please make sure that you are using adGroups() instead of AdGroup on line 6.  Your code should be as follows:
var adGroupIterator = AdWordsApp.adGroups().get();

Thanks,
Tyler Sidell
AdWords Scripts Team

aitor.uda...@gmail.com

unread,
Jun 28, 2016, 12:00:30 PM6/28/16
to AdWords Scripts Forum
Thanks Tyler Sidell.

I have another question,
I want to do is take the ad groups and put them on a sheet , then take those campaigns ad groups and put them in another column of the same sheet and then get the keywords of the ads and put it on a sheet .

For now I could only pick ad groups and keywords all account , but that's not what I wanted .

Not if you can help me ?

Thank you

Tyler Sidell (AdWords Scripts Team)

unread,
Jun 28, 2016, 4:32:02 PM6/28/16
to AdWords Scripts Forum
Hi,

Have you thought about simplifying the process and using Reports instead?  You could cross-check the type of report along with the fields needed.  Here is an example of a Keyword Performance Report that will output the information that you asked for.

function main() {
 
var SPREADSHEET_URL = "REPLACE_WITH_YOUR_SPREADSHEET_URL";

 
var sheetprueba = SpreadsheetApp.openByUrl(SPREADSHEET_URL);//abrimos sheet

 
var sheet = sheetprueba.getActiveSheet();
 
 
var report = AdWordsApp.report("SELECT CampaignName, AdGroupName, Criteria FROM KEYWORDS_PERFORMANCE_REPORT during LAST_MONTH");

  report
.exportToSheet(sheet);

 
Logger.log("Report ready! Visit the following URL to see it:");

 
Logger.log("https://docs.google.com/spreadsheet/ccc?key=" + sheetprueba.getId());
}

Thanks,
Tyler Sidell
AdWords Scripts Team
Message has been deleted

aitor.uda...@gmail.com

unread,
Jul 6, 2016, 5:57:06 AM7/6/16
to AdWords Scripts Forum

Hello, again not because my message was deleted ? The question I have is how do I get the values ​​of name, phone, and email form through gclid ? regards

Tyler Sidell (AdWords Scripts Team)

unread,
Jul 6, 2016, 10:48:34 AM7/6/16
to AdWords Scripts Forum
Hi,

Would you mind opening a new thread pertaining to this new question?  Please provide as much detail as possible.

Thanks,
Tyler Sidell
AdWords Scripts Team

Aitor Udabe

unread,
Jul 6, 2016, 10:54:54 AM7/6/16
to AdWords Scripts Forum
Reply all
Reply to author
Forward
0 new messages