Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wpsmith/f6117e4baef8c8569c6ed4403b1b1789 to your computer and use it in GitHub Desktop.
Save wpsmith/f6117e4baef8c8569c6ed4403b1b1789 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