var workingDateRange = "LAST_14_DAYS"; function main() { lowerBidsToTopKeywords(); raiseBidsToMidPositionKeywords(); raiseBidsToLowPositionKeywords(); } function lowerBidsToTopKeywords () { //Anything better than this needs to be bid down a bit. var idealAveragePosition = 2.1; //Let's lower the bids 10% var adjustment = 10 / 100; //Get all enabled keywords that have an average position //better than idealAveragePosition var keywords = AdWordsApp.keywords() .withCondition("Status = ENABLED") .withCondition("AdGroupStatus = ENABLED") .withCondition("CampaignStatus = 'ENABLED'") .withCondition("AveragePosition < " + idealAveragePosition) .forDateRange(workingDateRange) .get(); while (keywords.hasNext()) { var keyword = keywords.next(); keyword.setMaxCpc(keyword.getMaxCpc() * (1 - adjustment)); } } function raiseBidsToMidPositionKeywords () { //This is where we want to be. var idealAveragePosition = 2.1; //Anything better than this but worse than Ideal //needs their bids increased moderately. var notSoTerribleYetLowPosition = 5.9 //Let's increase the bids 20% var adjustment = 20 / 100; //Get all enabled keywords that have an average position //worse than idealAveragePosition but //better than notSoTerribleYetLowPosition var keywords = AdWordsApp.keywords() .withCondition("Status = ENABLED") .withCondition("AdGroupStatus = ENABLED") .withCondition("CampaignStatus = 'ENABLED'") .withCondition("AveragePosition > " + idealAveragePosition) .withCondition("AveragePosition < " + notSoTerribleYetLowPosition) .forDateRange(workingDateRange) .get(); while (keywords.hasNext()) { var keyword = keywords.next(); keyword.setMaxCpc(keyword.getMaxCpc() * (1 + adjustment)); } } function raiseBidsToLowPositionKeywords () { //Anything below this needs urgent help var lowestPossibleAveragePosition = 6; //Let's increase the bids 40% var adjustment = 40 / 100; //Get all enabled keywords that have an average position //worse than lowestPossibleAveragePosition var keywords = AdWordsApp.keywords() .withCondition("Status = ENABLED") .withCondition("AdGroupStatus = ENABLED") .withCondition("CampaignStatus = 'ENABLED'") .withCondition("AveragePosition > " + lowestPossibleAveragePosition) .forDateRange(workingDateRange) .get(); while (keywords.hasNext()) { var keyword = keywords.next(); keyword.setMaxCpc(keyword.getMaxCpc() * (1 + adjustment)); } }