But I do not know whether it is active or not ? And my money and location is in Viet Nam, should I change "$" to "VNĐ".
//Google Ads script for modifying targeted location bid adjustments.
//Feel free to change the values before the main function.
//Bid modifiers are returned as follows:
// 0 = - 100%
// 1 = 0%
// 2 = + 100%
//Editable values;
var cpaTreshold = 60;
var costTreshold = 80;
var increaseBid = 0.10;
var decreaseBid = 0.05;
function main() {
//Selects campaigns based on the given conditions;
var campaigns = AdsApp.campaigns()
.withCondition('Status = ENABLED')
.withCondition('Name CONTAINS_IGNORE_CASE "Global"')
.withCondition('Name DOES_NOT_CONTAIN_IGNORE_CASE "display"')
.get();
//Loops through the selected campaigns campaigns;
while (campaigns.hasNext()) {
var campaign = campaigns.next();
Logger.log('Currently running campaign: ' + campaign.getName());
//Selects the targeted location of a campaign;
var locations = campaign.targeting().targetedLocations().get();
//Loops through the selected targeted locations;
while (locations.hasNext()) {
var location = locations.next();
//Gets the current bid adjustment of a selected location;
var bidAdjustment = location.getBidModifier();
//Gets the statistics for the selected location
var cost = location.getStatsFor('LAST_30_DAYS').getCost();
var conversions = location.getStatsFor('LAST_30_DAYS').getConversions();
//Calculates the CPA of a selected location. Returns 0 if there were 0 conversions;
if (conversions == 0) {
var cpa = 0;
} else {
var cpa = (cost / conversions).toFixed(2);
}
//Returns a nice log message :)
Logger.log(location.getName() + ': Cost = Đ' + cost + ', Conversions = ' + conversions + ', with a CPA of Đ' + cpa);
//Adjusts the bid modifiers according to the set values;
if (cost > costTreshold && conversions == 0) {
location.setBidModifier(bidAdjustment - decreaseBid);
}
if (cpa > cpaTreshold) {
location.setBidModifier(bidAdjustment - decreaseBid);
}
if (cpa < cpaTreshold && conversions != 0) {
location.setBidModifier(bidAdjustment + increaseBid);
}
}
}
}