function getDayofWeek() {
var today = new Date();
//Returns a number 0-6. Sunday is 0, Monday is 1, etc.
var dayOfWeek = today.getDay();
var maxBid = 0;
var time = today;
//Checks if it is a weekend
if (dayOfWeek == 6 || dayOfWeek == 0) {
maxBid = 0.03;
} else
maxBid = 1.00;
var adGroupSelector = AdWordsApp.adGroups().get();
while (adGroupSelector.hasNext()) {
var ag = adGroupSelector.next();
ag.bidding().setCpa(maxBid);
}
return maxBid;
}
function main() {
getDayofWeek();
}
function main() {
var accountSelector = MccApp.accounts()
.withLimit(50);
// Process the account in parallel. The callback method is optional.
accountSelector.executeInParallel('updateProductGroupBidBasedOnAdGroup', null);
}
function updateProductGroupBidBasedOnAdGroup() {
var maxBid = getDayofWeek();
var productGroups = AdWordsApp.productGroups()
.withCondition("AdGroupName CONTAINS '.'")
.withCondition("CampaignName STARTS_WITH 'DA'")
.withCondition("CampaignStatus != REMOVED")
.withCondition("PartitionType != SUBDIVISION")
.withCondition("AdGroupStatus != REMOVED")
.get();
while (productGroups.hasNext()) {
var productGroup = productGroups.next();
var adGroupCpc = parseFloat(productGroup.getAdGroup().bidding().getCpc());
var adGroupCpcName = parseFloat(productGroup.getAdGroup().getName().substr(0,4));
if(adGroupCpcName != adGroupCpc)
adGroupCpc = adGroupCpcName;
if(adGroupCpc != productGroup.getMaxCpc()){
//checks max bid
if(adGroupCpcName > maxBid)
adGroupCpc = maxBid;
//checks min bid
else if(adGroupCpcName < 0.03)
adGroupCpc = 0.03;
productGroup.setMaxCpc(adGroupCpc);
}
}
}
function getDayofWeek(){
var today = new Date();
//Returns a number 0-6. Sunday is 0, Monday is 1, etc.
var dayOfWeek = today.getDay();
var maxBid = 0;
var time = today;
//Checks if it is a weekend
if(dayOfWeek == 0 || dayOfWeek == 6){
maxBid = 0.50;
}
else
maxBid = 1.2;
return maxBid;
}
if(dayOfWeek == 0 || dayOfWeek == 6){
maxBid = 0.50;
}
else
maxBid = 1.2;
return maxBid;
if (dayOfWeek == 0 || dayOfWeek == 6) {
maxBid = 0.50;
} else
maxBid = 1.2;
return maxBid;
function main() { var accountSelector = MccApp.accounts() .withLimit(50); // Process the account in parallel. The callback method is optional. accountSelector.executeInParallel('updateProductGroupBidBasedOnAdGroup', null);}
function updateProductGroupBidBasedOnAdGroup() {
var maxBid = getDayofWeek();
var productGroups = AdWordsApp.productGroups() .withCondition("AdGroupName CONTAINS '.'")
.withCondition("CampaignName CONTAINS 'shopping'")
maxBid = 0.11;
} else maxBid = 1.00; return maxBid;}