Skip to content

Instantly share code, notes, and snippets.

@daniel-c05
Last active April 9, 2019 16:19
Show Gist options
  • Save daniel-c05/de2502a0a0dd314b1558 to your computer and use it in GitHub Desktop.
Save daniel-c05/de2502a0a0dd314b1558 to your computer and use it in GitHub Desktop.
AdWords Scripts - Perform Basic Bid Management
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));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment