Hi Nathan,
Thanks for providing further details.
If you want to get the data of the headline part 2 from a specific cell of the spreadsheet, you can specify the cell address of this cell in the
getRange() method of
SpreadsheetApp.
In your case, you can refer to the sample code below to have an idea with the provided suggestion.
function main() {
var SPREADSHEET_URL = 'INSERT_SPREADSHEET_URL_HERE';
// Name of the specific sheet in the spreadsheet.
var SHEET_NAME = 'INSERT_SHEET_NAME_HERE';
var ss = SpreadsheetApp.openByUrl(SPREADSHEET_URL);
var sheet = ss.getSheetByName(SHEET_NAME);
var cell = sheet.getRange('A1');
var cellValue = cell.getValue();
Logger.log(cellValue);
}
Furthermore, for you convenience, you can refer to the sample script below if you want to create multiple expanded text ads.
function main() {
var SPREADSHEET_URL = 'INSERT_SPREADSHEET_URL_HERE';
// Name of the specific sheet in the spreadsheet.
var SHEET_NAME = 'INSERT_SHEET_NAME_HERE';
var ss = SpreadsheetApp.openByUrl(SPREADSHEET_URL);
var sheet = ss.getSheetByName(SHEET_NAME);
var range = sheet.getRange(2, 1, sheet.getLastRow(), sheet.getLastColumn());//Get the data of the spreadsheet from second row to the last row
var values = range.getValues();
for (var i = 0; i < sheet.getLastRow()-1; i++) {
var adGroupSelector = AdsApp
.adGroups().withIds(INSERT_ADGROUP_ID_HERE);//Put the ad group ID where you want to create expanded text ads
var adGroupIterator = adGroupSelector.get();
while (adGroupIterator.hasNext()) {
var adGroup = adGroupIterator.next();
adGroup.newAd().expandedTextAdBuilder()
.withHeadlinePart1(values[i][0])
.withHeadlinePart2(values[i][1])
.withDescription(values[i][2])
.withPath1(values[i][3])
.withPath2(values[i][4])
.withFinalUrl(values[i][5])
.build();
}
}
}
If you are going to use the sample script, I would suggest to format the spreadsheet based on the screenshot below. The script is constructed based on the format of the spreadsheet below.
Lastly, this script is working on my end. However, I would recommend to
preview this script to see if it will execute successfully and if the simulated results are fine.
Let me know if you have further questions.