Skip to content

Instantly share code, notes, and snippets.

@vhsu
Created January 27, 2018 10:26
Show Gist options
  • Save vhsu/10472d460c8d97e6331c2fc0f3fa797f to your computer and use it in GitHub Desktop.
Save vhsu/10472d460c8d97e6331c2fc0f3fa797f to your computer and use it in GitHub Desktop.
Adwords Script - Add KeyWords Based on Ad group Name
//-----------------------------------
// Create Keywords based on Ad Group Name
//
// : Ads a new Ad with a headline using the keyword with the most impressions
// Author : Vincent Hsu
// Website: http://www.suisseo.ch
//-----------------------------------
// Done for France
function main() {
index=0;
// Let's start by getting all of the adGroups that are active
var ag_iter = AdWordsApp.adGroups()
.withCondition("Status = ENABLED")
.withCondition("CampaignStatus = ENABLED")
.withCondition("CampaignName CONTAINS_IGNORE_CASE 'Allemagne - DE - search'")
.forDateRange("ALL_TIME")
.get();
// Then we will go through each one
while (ag_iter.hasNext()) {
var ag = ag_iter.next();
function trim (myString)
{
return myString.replace(/^\s+/g,'').replace(/\s+$/g,'')
}
//Logger.log(trim(ag.getName().replace('Wahrsagen ','')));
ag.createKeyword("[wahrsager "+trim(ag.getName().replace('Wahrsagen ','').replace('"',''))+"]")
ag.createKeyword("[wahrsager in "+trim(ag.getName().replace('Wahrsagen ','').replace('"',''))+"]")
ag.createKeyword("[wahrsagen "+trim(ag.getName().replace('Wahrsagen ','').replace('"',''))+"]")
ag.createKeyword("[wahrsagen in "+trim(ag.getName().replace('Wahrsagen ','').replace('"',''))+"]")
ag.createKeyword("[wahrsagerin "+trim(ag.getName().replace('Wahrsagen ','').replace('"',''))+"]")
ag.createKeyword("[wahrsagerin in "+trim(ag.getName().replace('Wahrsagen ','').replace('"',''))+"]")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment