AdWords
4.7K members online now
4.7K members online now
Dive into advanced features like Remarketing, Flexible Bid Strategies, AdWords Editor, and AdWords Scripts
Guide Me
star_border
Reply

AdWords Countdown Script Multiple AdGroups

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

Hi,

 

I'm having trouble updating multiple ad groups with the countdown script. It works fine targeting one ad group but after following the instructions to update multiple ad groups, it doesn't seem to do anything.

 

Thanks

 

J

 

Script:

// Date to use to find out how many days are remaining.
var END_DATE = new Date('May 09, 2014');
// Change this to the Ad Group you set up with text ads with AdParams.
var AD_GROUP_NAME = ['adgroupexample1', 'adgroupexample2'];

function main() {
var timeLeft = calculateTimeLeftUntil(END_DATE);
var adGroups = getAdGroups(AD_GROUP_NAMES);
while (adGroups.hasNext()) {
var adGroup = adGroups.next();
var keywords = adGroup.keywords().get();
// ...
var keywords = adGroup.keywords().get();
while (keywords.hasNext()) {
var keyword = keywords.next();
// We want to update {param1} to use our calculated days and {param2} for hours.
keyword.setAdParam(1, timeLeft['days']);
keyword.setAdParam(2, timeLeft['hours']);
}
}

var DAY_IN_MILLISECONDS = 1000*60*60*24;

function calculateTimeLeftUntil(end) {
var current = new Date();
var timeLeft = {};
var daysFloat = (end - current) / (DAY_IN_MILLISECONDS);
timeLeft['days'] = Math.floor(daysFloat);
timeLeft['hours'] = Math.floor(24 * (daysFloat - timeLeft['days']));
return timeLeft;
}

function getAdGroups(names) {
var predicateValues = "['" + names.join("','") + "']";
Logger.log(predicateValues);
return AdWordsApp.adGroups()
.withCondition('Name IN ' + predicateValues)
.withLimit(names.length)
.get();
}
}

1 Expert replyverified_user
Marked as Best Answer.
Solution
Accepted by Shanea K (Google Employee)
September 2015

Re: AdWords Countdown Script Multiple AdGroups

Google Employee
# 2
Google Employee

Hi Jfield,

 

Thanks for your question.

 

A better place for this question might be the AdWords scripts forum. Here is an answer to a similar question in that forum. 

 

Hope that helps. 

Re: AdWords Countdown Script Multiple AdGroups

Visitor ✭ ✭ ✭
# 3
Visitor ✭ ✭ ✭
Thanks Shanea! Your link has solved the problem Smiley Happy