Hi,
I have recently started working on google scripts and I would like to ask for help on the following case:
I am running a Target CPA bid strategy campaign (Automated Bidding), and I notice that certain keywords have a very high conversion rate. So, I would like to improve the top of page Impression or increase the Keywords bid to have the ads show up on the Top.
Is it possible? I have researched and it seems to be possible to fine-tune an automated bidding strategy.
Here is the script I worked on:
function main() {
// Define the label used to identify target keywords
var LABEL_NAME = "Top_Position"; // Replace with your label name
var bidIncreasePercentage = 0.2; // Increase bid by %
// Define the maximum CPC limit
var MAX_CPC_LIMIT = 12.00; // Adjust the limit as needed
// Email address to send notifications
var EMAIL = "my_email";
// Initialize a variable to track changes
var changesMade = false;
var changeLog = [];
// Get the keywords with the specific label
var keywordsIterator = AdsApp.keywords()
.withCondition("LabelNames CONTAINS '" + LABEL_NAME + "'")
.get();
while (keywordsIterator.hasNext()) {
var keyword = keywordsIterator.next();
// Get the first position bid estimate
var stats = keyword.getStatsFor("LAST_30_DAYS"); // Adjust the date range if needed
var firstPageCpc = stats.getFirstPageCpc();
var topOfPageCpc = stats.getTopOfPageCpc();
var firstPositionCpc = stats.getFirstPositionCpc();
var currentCpc = keyword.bidding().getCpc();
// Increase the bid by bidIncreasePercentage, respecting the maximum CPC limit
if (firstPositionCpc !== null) {
var newCpc = currentCpc * (1 + bidIncreasePercentage);
if (newCpc <= MAX_CPC_LIMIT) {
keyword.setMaxCpc(newCpc);
changesMade = true;
changeLog.push("Keyword: '" + keyword.getText() + "', Label: '" + LABEL_NAME + "', New CPC: " + newCpc + ", First Position Bid: " + firstPositionCpc + ", Max CPC Limit: " + MAX_CPC_LIMIT);
Logger.log("Keyword: '" + keyword.getText() + "', Label: '" + LABEL_NAME + "', New CPC: " + newCpc + ", First Position Bid: " + firstPositionCpc + ", Max CPC Limit: " + MAX_CPC_LIMIT);
} else {
Logger.log("Keyword: '" + keyword.getText() + "', Label: '" + LABEL_NAME + "', Current CPC: " + currentCpc + " increased by " + bidIncreasePercentage*100 + "% would exceed Max CPC Limit.");
}
} else {
Logger.log("Keyword: '" + keyword.getText() + "', Label: '" + LABEL_NAME + "': No first position bid estimate available.");
}
}
// Send email notification if changes were made
if (changesMade) {
var subject = "Bid Changes Made in Google Ads Script";
var body = "The following changes were made:\n\n" + changeLog.join("\n");
MailApp.sendEmail(EMAIL, subject, body);
}
}