Hi ads
I created a script to control my budget based on location,
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Đ".
Please check my script below:
//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);
}
}
}
}
--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
---
You received this message because you are subscribed to the Google Groups
"AdWords API and Google Ads API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/adwords-api/b8e541d6-0ff0-4bca-9396-f363a4406697n%40googlegroups.com.