Targeted Optimizations
Wed Feb 21 2024 17:14:51 GMT+0000 (Coordinated Universal Time)
Saved by
@tchives
#javascript
function main() {
// Target Locations (Adjust this list!)
var targetLocations = [
"California",
"New York",
"Texas"
];
// Bid Adjustments (Positive = Increase, Negative = Decrease)
var locationBidModifiers = {
"California": 0.20, // Increase bids by 20% in California
"New York": 0.10, // Increase bids by 10% in New York
"Texas": -0.15 // Decrease bids by 15% in Texas
};
// Campaign Selection
var campaignName = "Campaign Name";
// Get all the location criteria within the specified campaign
var locationIterator = AdsApp.campaigns()
.withCondition("Name = '" + campaignName + "'")
.get()
.targeting().locations();
while (locationIterator.hasNext()) {
var location = locationIterator.next();
var locationName = location.getName();
// Check if the location is in our target list
if (targetLocations.indexOf(locationName) !== -1) {
var bidModifier = locationBidModifiers[locationName];
// Set the bid modifier only if it exists
if (bidModifier) {
location.setBidModifier(1 + bidModifier);
}
}
}
}
content_copyCOPY
Use code with caution.
Comments