Script 1: Creates new ETA
function main() {
var accountIterator = MccApp.accounts().get();
while (accountIterator.hasNext()) {
var account = accountIterator.next();
MccApp.select(account);
Logger.log(account.getName());
//Create an expanded text ad for your specific string (i.e. on your use-case, "2018").
//Please see this documentation for more information on how to create an expanded text ad.
var adGroupIterator = AdWordsApp.adGroups()
.get();
if (adGroupIterator.hasNext()) {
var adGroup = adGroupIterator.next();
//you may insert your string to any part of the ad conditions. Here, inserting 2018 on HeadlinePart2 is just an example
adGroup.newAd().expandedTextAdBuilder()
.withHeadlinePart1('INSERT_HEADLINE_P1_HERE')
.withHeadlinePart2('INSERT_HEADLINE_P2_HERE 2018')
.withDescription('INSERT_DESCRIPTION_HERE')
.withFinalUrl('INSERT_FINAL_URL_HERE')
.build();
}
}
}
Script 2: Deletes old ETAs
function main() {
// Selects all accounts using the ManagedAccountSelector object. You may see this example on how to get all accounts.
var accountIterator = MccApp.accounts().get();
while (accountIterator.hasNext()) {
var account = accountIterator.next();
MccApp.select(account);
Logger.log(account.getName());
var adSelector = AdWordsApp
.ads()
//you may change this depending on your requirements
.withCondition("HeadlinePart1 CONTAINS '2017'");
var adIterator = adSelector.get();
while (adIterator.hasNext()) {
var ad = adIterator.next();
//Deletes your ETA with field containing "2017". You may see this documentation about .withCondition() for more details.
ad.remove();
}
}
}