Count Up Your Conversions with AdWords Countdown Scripts

July 23, 2018


Who doesn’t love a countdown? Countdowns can be used at any time, whether it’s New Year’s Eve, a rocket launch, or you just want to get people excited for something that’s about to happen (unless it’s a choreographed dance you came up with at a family party). You can also tactically set up a countdown whenever you announce a release date for a product/service or an upcoming sale.


If you have set up an AdWords campaign around an upcoming sale – such as a site-wide “50% Off” sale or a holiday sale – and tried to reflect this in your ad copy. Sometimes a deal speaks for itself and you see results right away. But you also want to create a sense of urgency for consumers to purchase your goods. Up-to-date values in ad text can have an amazing impact for consumers when it comes to these limited-time offers.

One cool way to do this is to add dynamic parameters to your ad copy. If you recall, including ad text parameters can be a sneaky way to double your CTRs. In particular, Google offers a Sale Countdown Script that will automatically update your ad copy with a countdown. AdWords Scripts are a great way to automate actions in your account by entering JavaScript code. This particular script allows you update numeric values in text ads without having to pause and re-create the ad or wait for policy checks.

How to Set Up Countdown Scripts in AdWords

So how do you set these up, you ask? Well, let’s walk through the steps to get you on your way to counting down to more conversions.

Whether you have an upcoming sale or you’re a deals site, countdown parameters are a great way to show viewers what they can expect and when they can expect it. In order to add these parameters correctly to your ad copy, you will need to follow these seven steps:

Step 1

Select or create an ad group. You can also select or create a campaign, but we will get to that in a little bit.  

Step 2

Create ad copy with the parameters {param1:few} for days and {param2:&} for hours. These can be used in the headline and description lines 1 & 2

Step 3

Create a new AdWords Script by clicking on ‘Bulk Operations’ in the Navigation Panel of your AdWords account > ‘Scripts’ > then click “+ SCRIPT”

adwords script

Step 4

Enter this source code:

// Date to use to find out how many days are remaining. var END_DATE = new Date('December 21, 2012'); // Change this to the Ad Group you set up with text ads with AdParams. var AD_GROUP_NAME = 'Widget Sale'; 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(); } }


  • The 2 most important things to pay attention to are the values in the end date variable and the ad group name variable. These will be the two values you will provide.
  • You can add multiple ad groups for this one script, say if you want to target multiple product/brand ad groups with the same sale, by changing var AD_GROUP_NAME to var AD_GROUP_NAMES & adding the various ad groups in the variable as such ‘Coat Sale, Coat Sale 2, Book Sale’
  • You can also target a campaign for a particular countdown. All you would need to do in the code is change the various versions of ‘Ad group’ with ‘Campaign’. Example, var AD_GROUP_NAME would become var CAMPAIGN_NAME

Step 5

In addition to these dynamic parameters, you can add more code to adjust for keyword bids as the sale nears/comes to an end. You are allowed to select the number of days left, in which the bids will change. The bids will adjust to be at the top of the page. It would look as such (the highlighted sequence would be added to the main function):

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']); if (timeLeft['days'] < 5) { keyword.setMaxCpc(keyword.getTopOfPageCpc()); } else { keyword.setMaxCpc(keyword.getFirstPageCpc()); } }

Step 6

Once you have the script finalized, run a preview and then save it.

Step 7

Lastly, you will want to make sure the script is scheduled to run hourly, meaning the script will dynamically change the ads to adjust for the countdown by the hour.

And voila! Your countdown ad will look something like this:

countdown script

While setting up the script and ads might be a bit difficult at first, in the end you’ll have dynamic ads that will stand out against your competition. There are a number of uses outside just sales – number of days before a movie, TV show, album, or event takes place, etc. The script will be especially helpful during the holiday season to let those last-minute shoppers know just how much time they have left to Christmas!

Check out five more great AdWords scripts for beginners.

Sign up to get our top tips and tricks weekly!