Hi,
I am trying to get keyword data to a Google sheet, but I'm struggling to find a way to structure the labels in a way that lets me export them correctly (all of them, on the same row as campaign and keyword). The structure I'm looking for is the way the data is pushed to the report array below, but I can't figure out how to loop through the labels in a way that accomplishes it. Been experimenting with sub/super arrays to no avail. Can anyone offer some guidance?
function main() {
const query = "SELECT
campaign.name, ad_group_criterion.keyword.text, ad_group_criterion.labels FROM keyword_view WHERE
campaign.name IN ('Brand')";
const search = AdsApp.search(query);
let report = [];
while (search.hasNext()) {
let row = search.next();
let campaign =
row.campaign.name;
let keyword = row.adGroupCriterion.keyword.text;
let label = row.adGroupCriterion.labels;
report.push([[campaign],[keyword],[label[0]],[label[1]],[label[2]]]);
}
console.log(report);
}
Any help or pointer much appreciated!