User Tools

Site Tools


automatic_negatives

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

automatic_negatives [2015/07/28 15:11] (current)
vincenzo created
Line 1: Line 1:
 +<code javascript>​
 +// You can use this approach when you have only minimal processing to
 +// perform in each of your client accounts.
  
 +function main(){
 +
 +  // Select the accounts to be processed. You can process up to 50 accounts.
 +  var accountSelector = MccApp.accounts()
 +   ​.withCondition("​Impressions > 100")
 +   ​.withCondition("​Name CONTAINS '​SEARCH'"​)
 +   ​.forDateRange("​LAST_30_DAYS"​)
 +   ​.withLimit(50);​
 +    ​
 +  // Process the account in parallel. The callback method is optional.
 +  accountSelector.executeInParallel('​processAccount',​ '​allFinished'​);​
 +}
 +
 +    // Select the accounts to be processed & the time frame
 + 
 +    var account = AdWordsApp.currentAccount();​
 +    var accountName = account.getName();​
 +      Logger.log('​%s',​accountName);​
 +      MccApp.select(account);​
 +      ​
 +      var campaignIterator = AdWordsApp.campaigns()
 +      .withCondition("​Name CONTAINS '​{e}'"​)
 +      .get();
 +      ​
 +      ​
 +      while (campaignIterator.hasNext()) {
 +        var campaign = campaignIterator.next();​
 +
 +        ​
 +        var keywordIterator = campaign.keywords()
 +        .withCondition('​Impressions > 5')
 +        .forDateRange('​LAST_30_DAYS'​)
 +        .get();
 +        ​
 +        while (keywordIterator.hasNext()) { 
 +          var keyword = keywordIterator.next();​
 +
 +          Logger.log("​Campaign:​ " + campaign.getName() + " - Exact Keyword: " + keyword.getText()); ​         ​
 +          var exact_campaign_name = campaign.getName();​
 +          var broad_campaign_name = exact_campaign_name.replace("​{e}","​{b}"​);​
 +          var broad_campaign_iterator = AdWordsApp.campaigns()
 +             ​.withCondition("​Name = "+ "'"​ + broad_campaign_name + "'"​ + ""​)
 +             ​.get();​
 +          while (broad_campaign_iterator.hasNext()) {
 +           var broad_campaign=broad_campaign_iterator.next();​
 +           var negativeKeyword = keyword.getText();​
 +           ​broad_campaign.createNegativeKeyword(negativeKeyword);​
 +           ​Logger.log("​Campaign:​ " + broad_campaign + " - Negative: " + negativeKeyword);​
 +          }
 +          }
 +}
 +
 +</​code>​
automatic_negatives.txt ยท Last modified: 2015/07/28 15:11 by vincenzo