Advertisement
  1. SEJ
  2.  ⋅ 
  3. PPC

How to Be Awesome At AdWords Scripting

By learning the fundamentals of JavaScript, it’s possible to customise and extend the power of AdWords to meet our clients’ needs.

How to Be Awesome At AdWords Scripting

AdWords scripts provide many ways to take PPC accounts to the next level with a (reasonably) straightforward  method of streamlining repetitive tasks.  This frees up time and allows the creation of advanced automations that just wouldn’t be possible to implement manually.

To unlock the full potential of automation, you need to build an application based on the AdWords API, but that is much more complex and  likely requires the know-how of a specialist developer. AdWords scripts, on the other hand, require only entry-level familiarity with JavaScript, and since the programming interface is within AdWords itself, you can be up and running with your first script in minutes.

There are lots of great resources available online with ideas for how AdWords Scripts can be used to drive efficiencies and get the most of an account, starting with Google’s own tools and examples. By learning the fundamentals of JavaScript, however, it’s possible to customize and extend the power of these solutions.

Below are just a few examples of how our company has adapted scripts found online to meet our clients’ needs.

1. Extracting Content From Landing Pages

This example is based on the awesome Russell Savage’s script to check URLs for problematic header response codes (eg. 404 Not Found errors). His original script runs through all ad or keyword destination URLs and produces a report outlining any problems; Russell later modified his own script on the same site to scan for text strings in the page (eg. ‘sorry’, ‘out of stock’, etc).

A further extension to that – extremely simple but powerful – would be to replace the static text string that you’re looking for with a regular expression, which can be used with wildcards to match any predefined pattern. The interesting part is the actual value that the wildcard is matched with can then be accessed and used however you chose.

For example, say we have a client where the number of products on a category page is always listed in the format ‘Your search returned X results’, and in the source code of the page you see that this is displayed like so:

adscripts

Then to access this figure (eg. the ‘33’ here), we can pull the source code of the page URL as in Russell’s example:

source code

And then construct the regular expression based on this pattern we’ve identified:

regular expression

Assuming the page under consideration does contain a line written in this format, then the content of the resulting array, resultsArray[1], will then hold the actual value found – in this case, 33, the number of products in stock.

This piece of data can be use in various ways: if you’re capturing the price of a product, or as with the example above, the number of products in a product category, you can use this in conjunction with ad parameterisation to have ads that include information straight from the landing page. Alternatively, maybe you’d want to automatically adjust bids based on product price, or pause an ad group if stock falls below a certain threshold.

2. URL Validation

Another example using a little regex. This was called for when we had a client who required all keyword-level URLs to be manually tagged with a series of custom tracking parameters. Since this was an account that multiple people worked on and was frequently updated, we needed a way to ensure that all URLs were being set up in a consistent manner.

In this simplified example, we’re assuming it’s Google Analytics manual tagging that needs to be in place, but this could be modified to check for Omniture, a client’s custom tagging, etc.

Similar to before, we start by constructing a regular expression, this time to match against URLs that are manually tagged with utm_source=google, utm_medium=cpc, and utm_campaign=[some series of alphanumeric characters, represented here by the \w wildcard] –

regular expression

Then, we construct a keyword selector, and loop through our selection testing each keyword’s destination URL against the regex, labeling any failed matches to deal with later:

keyword selector

At the end of the main routine, a separate subroutine could select all keywords so labeled, and email out that list emailed for manual review.

3. Modified Ad Countdown Script

One of Google’s first offerings was the ad countdown script, which uses ad parameters to automatically update ad text on the countdown to (in Google’s example) the start of a sale.

To set this up, you create an ad description line using the ad parameters which will be dynamically updated by the script. For example: ‘Only {param1:a few} days, {param2:and} hours left – Everything must go!’ However, if you run with the script as it is, then you end up some ugly singular/plural mismatches, such as:

adscripts holiday sale

Fortunately, it’s an easy enough modification to add a check into the script to take note of when there is only, say one hour in a day, at which point you need to pause the ad and activate a second singular version instead. For example:

adscripts

Of course if you’re utilizing both the number of days and hours in your ad texts, then things get more complicated, as you end up needing four ad templates writing, namely:

  • Plural days, plural hours
  • Plural days, singular hour
  • Singular day, plural hours
  • Singular day, singular hour

And then the pause/unpause rules get more complicate too, but the principle would be exactly the same as outlined above.

Other scripts we’ve created or adapted for our clients have allowed us to create automated daily and weekly reports for clients and ourselves, dynamic ad texts that update based on product feeds, alerts to flag up anomalous account behavior, and ad groups that are paused or re-enabled dependent on stock levels.

There are plenty of ‘plug and play’ example scripts available on the web that I would encourage anyone to have a go at implementing, but hopefully the handful of examples above show that investing some time to learn at least the fundamentals of JavaScript can enable you to go beyond the standard, to customize and extend the power of these solutions in any number of ways.

If you have any other ideas for account automation, I’d love to hear them!

 

Image Credits

Featured Image: Created by author for Search Engine Journal
Image #1: Ingvar Bjork via Shutterstock

Category PPC
ADVERTISEMENT
Ian Harris Search Laboratory

Ian Harris is the CEO and founder of leading multlingual search marketing agency, Search Laboratory. He is a specialist in ...