AdWords
2.1K members online now
2.1K 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 - Whole Account Possible?

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

Hi there,

 

I am trying to implement the Sale Countdown script found here:

 

https://developers.google.com/adwords/scripts/docs/tutorials/countdown-sale

 

I would like to be able to run the script for the whole account as opposed to just a few campaigns or adgroups.  The developers page only gives me the option to select a single campaign or multiple adgroups.  How would I run this for the whole account?

 

Thanks for your help. Here's my full script:

 

// Date to use to find out how many days are remaining.
var END_DATE = new Date('September 4, 2013');
// Change this to the Ad Group you set up with text ads with AdParams.
var AD_GROUP_NAME = 'Full-Face Helmets';

function main() {
var timeLeft = calculateTimeLeftUntil(END_DATE);
var adGroup = getAdGroup(AD_GROUP_NAME);
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 getAdGroup(name) {
var adGroupIterator = AdWordsApp.adGroups()
.withCondition('Name = "' + name + '"')
.withLimit(1)
.get();
if (adGroupIterator.hasNext()) {
return adGroupIterator.next();
}
}

Re: Adwords Countdown Script - Whole Account Possible?

Collaborator ✭ ✭ ✭
# 2
Collaborator ✭ ✭ ✭
Hello Lance D ! Welcome to the Community !

Please use the dedicated AdWords Scripts forum for this issue

https://groups.google.com/forum/m/#!forum/adwords-scripts

Re: Adwords Countdown Script - Whole Account Possible?

Visitor ✭ ✭ ✭
# 3
Visitor ✭ ✭ ✭
Thanks Adrian. Noob here using google forums.