我試圖寫一個腳本,將:通過在MCC所有帳戶在AdWords腳本中使用campaignSelector時,如何指定AdWords帳戶?
- 迭代,並選擇那些在名稱中有「SEM」。
- 遍歷帳戶中的廣告系列並選擇符合特定條件的廣告系列。
- 向我自己發送這些活動的列表。
我得到的問題是將帳戶循環鏈接到活動循環。
所以我的問題是,在AdWords腳本中使用campaignSelector時,如何指定AdWords帳戶?
如果我可以爲廣告系列迭代指定帳戶(而不是默認腳本所在帳戶的腳本),那麼我可以在其中包含一個包含我所選帳戶的數組。
謝謝。
劇本至今:
//This code is to be placed in an MCC, sift through accounts in that MCC that fit a certain criteria
//then in those selected accounts, sift through the campaigns that fit a certain criteria and add
//these to a report (report code yet to be added)
//The problem we have is getting the campaignSelector() function to ‘look’ at the account that has been passed through from the accountIterator() function
function main() {
var mccAccount = AdWordsApp.currentAccount();
var childAccounts = MccApp.accounts();
function accountIterator()
{
var accountSelector = MccApp.accounts()
.withCondition("AccountDescriptiveName CONTAINS 'SEM'")
.withCondition("Status = ENABLED");
var accountIterator = accountSelector.get();
while (accountIterator.hasNext())
{
var account = accountIterator.next();
var accountName = account.getName();
Logger.log(accountName);
campaignSelector(accountName); //This might be really wrong....
//Need to pass the account name through to the campaignSelector function
//so that the campaignSelector functions looks at the campaigns in the highlighted account
}
}
function campaignSelector()
{
//SELECT campaigns we're interested in
var account = AdWordsApp.currentAccount(); //Guessing that we might need to use this?
var campaignSelector = AdWordsApp.campaigns()
.withCondition("CampaignName CONTAINS 'Shoop'")
.withCondition("SearchExactMatchImpressionShare < 95")
.forDateRange("LAST_7_DAYS")
.withCondition("Status = ENABLED");
//GET an iterator to list the selected campaigns
var campaignIterator = campaignSelector.get();
//ITERATE through all selected campaigns
while (campaignIterator.hasNext())
{
var campaign = campaignIterator.next();
//Add campaign and account info to a report – to be coded seperately
}
}
}