Stay organized with collections
Save and categorize content based on your preferences.
AI-generated Key Takeaways
KeywordOperation represents the creation of a new keyword and executes upon calling getErrors, getResult, or isSuccessful.
For efficiency, store KeywordOperations in an array and execute methods after constructing all desired operations.
isSuccessful indicates operation success, getResult returns the new Keyword or null, and getErrors provides error details if unsuccessful.
An operation representing creation of a new keyword. Calling any
method
(getErrors,
getResult, or
isSuccessful)
will cause the operation to execute and create the keyword. To
make the script more efficient, it's recommended that you store the
operations in an array and only call these methods once you've constructed
all the operations you want.
For instance, this is how you would assign a label to newly created
keywords in an efficient manner:
//Forthepurposeofthisexample,supposethatthefetchKeywords()//functionfetcheskeyworddatafromyourdatasourceofchoice,sothat//keywordsToCreateisanarrayofstrings,whereeachstringisthetext//forakeyword.varadGroup=AdsApp.adGroups().get().next();varkeywordsToCreate=fetchKeywords();varkeywordOps=[];for(vari=0;i<keywordsToCreate.length;i++){keywordOps.push(adGroup.newKeywordBuilder().withText(keywordsToCreate[i]).build());}for(vari=0;i<keywordOps.length;i++){if(keywordOps[i].isSuccessful()){keywordOps[i].getResult().applyLabel('myLabel');}else{Logger.log('Errors from Keyword ['+keywordsToCreate[i]+']: '+keywordOps[i].getErrors());}}
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-23 UTC."],[],[]]