function main() {
let campaigns = AdsApp.campaigns().get();
if (!campaigns.hasNext()) {
Logger.log("没有找到任何广告系列。");
return;
}
console.log(campaigns.totalNumEntities());
while (campaigns.hasNext()) {
let campaign = campaigns.next();
Logger.log("找到广告系列: " + campaign.getName());
let adGroups = campaign.adGroups().get();
if (!adGroups.hasNext()) {
Logger.log("广告系列 " + campaign.getName() + " 中没有广告组。");
continue;
}
while (adGroups.hasNext()) {
let adGroup = adGroups.next();
let groupName = adGroup.getName().replace(/[\s&#]/g, '_');
let campaignName = campaign.getName().replace(/[\s&#]/g, '_');
// Logger.log("处理广告组: " + groupName + ",广告系列: " + campaignName);
adGroup.urls().setCustomParameters({adgroup: groupName, campaign: campaignName});
}
}
}
I want to find all web campaigns and inject url params ad group names and campaign names, but this above code can't find pmax campaigns. How can I find the campaigns I want ?