Google Ads

Using Google AdWords Countdown Script, for Urgency

One of the most powerful messages in advertising copy involves playing to your consumers’ sense of urgency. This notion is portrayed with terms such as “limited time offer” or “one-day sale,” with the goal of convincing the consumer to shop now instead of later. Many merchants consistently run sales, but the sense-of-urgency messaging is either missing or unconvincing. There is an option in Google AdWords, however, that dynamically populates your text ads with the time left until a sale ends or an event occurs. This feature is AdWords’ countdown script; it involves the use of JavaScript.

Here is an example of the countdown script used in an ad by a company (a client of my employer) selling Mother’s Day cards. The ad refreshes daily to show the consumer how many days are left until the holiday.

Counting down the days until Mother's Day

Counting down the days until Mother’s Day.

Going even further, you can set the script to showcase how many days and hours are left before a particular campaign ends. In this example, the merchant is offering $10 off the Seresto line of products.

Counting down the days until the offer ends.

Counting down the days until the offer ends: “Only 10 Days 10 Hours Left.”

Writing the Ads

Here is how to set up ads using the countdown script. You don’t need programming experience to use this feature. The instructions below give a detailed and easy-to-understand guide for implementing the script.

The first step is to create the ads with dynamic parameters. These parameters represent where days and hours will be dynamically generated. To include both time intervals (days and hours), add your chosen parameters into the following syntax.

{param1:a Few}

Here is how these parameters will look in the Seresto ad.

Ad with days and hours parameters.

Ad with days and hours parameters,

And since we’re counting only the days until Mother’s Day, we only need to use one parameter.

Ad with just days parameter.

Ad with just days parameter.

You can try different forms of messaging, but to run the script, at least one parameter is needed.

Creating the Script

Once your ads are written, you’re ready to create the script. To get to this area, click “Bulk operations” in the left-hand navigation of the AdWords interface. One of the bulk operations you will see is for scripts. Click the option to “Create and manage scripts” and then click the red “+ Script” button. You’ll then see a screen that will allow you to paste your script.

Setting up the script.

Setting up the script.

Here is where you will create your script. All you have to do is (a) copy the code below, (b) convert it to raw text, and (c) paste into the AdWords interface. The only two items that will need to be updated are the sale end date and the ad group where the ad is located.

Insert date to use to find out how many days are remaining.


Change this to the ad group you set up with text ads with AdParams.


function main() {
var timeLeft = calculateTimeLeftUntil(END_DATE);
var adGroup = getAdGroup(AD_GROUP_NAME);
var keywords = adGroup.keywords().get();
while (keywords.hasNext()) {
var keyword =;

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 + ‘”‘)
if (adGroupIterator.hasNext()) {

Here is what the final version of the script looks like after adding the end date and ad group name.

Final version of countdown script.

Final version of countdown script.

Before previewing the script, authorize Google to run it. Since this script will be making changes for you, Google requires your permission beforehand. Once permission is given, you can preview the script.

Assuming everything is working right, you should see a screen like the one below. If your countdown script is not working properly, then you will need to troubleshoot. Generally, a syntax error is the most common reason for a script not working. So double-check your script’s adherence to the provided code.

Preview countdown script results

Preview countdown script results.

Once everything is working properly, click the “Run script now” button. To ensure that the script runs hourly, you’ll have to set the appropriate schedule for it to run.

Set the refresh frequency.

Set the refresh frequency.

The script has now been created and will run hourly until the designated date.

Final Thoughts

I’ve found that this script provides the most value as the end date gets closer. This may seem obvious, but it backs up the notion of urgency and the necessity to act. Consumers might not notice that a sale “ends soon,” but the message could resonate when they are presented with the specific amount of time left.

This script also helps text ads stand out against Product Listing Ads. Text ads will always have their place but it’s no secret that PLAs are more eye-catching and profitable. Anything that can be done to enhance the look of text ads has value.

Thinking ahead, with the fourth quarter generally being the most profitable time of the year for merchants, the countdown script could play a huge role. Between Black Friday, Cyber Monday, and the holidays, merchants can create a sense of urgency in shoppers.

Matthew Umbro
Matthew Umbro
Bio   •   RSS Feed