AdWords Scripts For Every Level: Part 2, Intermediate Tips For Editing & Troubleshooting

google-adwords-bigA7-1920

This is the second in a three-part series on using AdWords Scripts. In the first part we covered how to read scripts. In part two, we go beyond the very basics and look at some of the issues that new scripts users run into.

I asked scripts whizzes, Frederick Vallaeys, former Googler and co-founder of AdWords tool company Optmyzr and Steve Hammer, president at search marketing firm RankHammer, for some tips they’d give to intermediate scripts users on editing and trouble shooting as well as how to decide when to use scripts versus ad customizers.

Editing AdWords Scripts

Once you understand the fundamentals of which piece does what in a script, it’s time to learn how to edit to make it meet your needs. This, of course, can get very advanced very quickly. Here we’ll look at how to take simple existing scripts and bend them to your will with just a few quick changes.

There are several places to find script templates that can be used as is or modified to suit your needs. The Google Developers site has a number of scripts, many of which can be used at either the MCC or account level.

Note that each of the reporting scripts on the Developers site also includes a link to a corresponding spreadsheet template for the report if you decide to use Google spreadsheets. You can also refer to and build off of these templates if you choose to create a new report. Sheets are then available in Google Drive.

adwords script templatesThere are also many simple scripts snippets examples in your AdWords accounts under “See examples” when you opt to add a new script.

example adwords script

Above is the text report example shown under “Reports” (I”ve scrolled down past the notes in the script, but the function is at the top). This default script provides a Campaign Performance Report that pulls campaigns with fewer than 10 impressions in the past 30 days.  That’s pretty limiting, but gives us a good base to work from.

It’s easy to change this script to report campaigns with fewer than 1,000 impressions and 10 clicks in the past thirty days. Note that the clicks variable is already included in the report (the bottom half of the script), so we don’t need to change anything there. I’ve made edits to the text report script in green below. The same similar changes could be made to the spreadsheets report script. The script below is from the text report template.

function runReport() {
  
  var spreadsheet = AdWordsApp.report(
    'SELECT CampaignName, Clicks, Impressions, Cost ' +
    'FROM   CAMPAIGN_PERFORMANCE_REPORT ' +
    'WHERE  Impressions < 1000 ' +
    'WHERE Clicks < 10 ' +
    'DURING LAST_30_DAYS');

  var rows = report.rows();
  while (rows.hasNext()) {
    var row = rows.next();
    var campaignName = row['CampaignName'];
    var clicks = row['Clicks'];
    var impressions = row['Impressions'];
    var cost = row['Cost'];
    Logger.log(campaignName + ',' + clicks + ',' + impressions + ',' + cost);
  }
}

If you wanted to pull an Ad Group Performance Report instead of a campaign report, you could modify the script this way (changes again in green). Here I’ve changed the report name to ADGROUP_PERFORMANCE_REPORT and added in the variable adGroupName and corresponding row name AdGroupName for my report. I also added adGroupName into the Logger log to check on it in Preview Mode.

function runReport() {
  
  var report = AdWordsApp.report(
    'SELECT CampaignName, AdGroupName, Clicks, Impressions, Cost ' +
    'FROM   ADGROUP_PERFORMANCE_REPORT ' +
    'WHERE  Impressions < 1000 ' +
    'WHERE Clicks < 10 ' +
    'DURING LAST_30_DAYS');

  var rows = report.rows();
  while (rows.hasNext()) {
    var row = rows.next();
    var campaignName = row['CampaignName'];
    var adGoupName= row['AdGroupName'];
    var clicks = row['Clicks'];
    var impressions = row['Impressions'];
    var cost = row['Cost'];
    Logger.log(campaignName + ',' adGroupName + ',' + clicks + ',' + impressions + ',' + cost);
  }
}

Troubleshooting Scripts

No matter how proficient you are at scripts, it’s easy to make mistakes. Luckily there are ways to ensure your scripts are running properly before they start executing changes to your account.

Vallaeys stresses the importance of always using “Preview Mode” to make sure your script is making the right changes. That’s the big red “Preview” button above the script editing window. It’s also a good idea to make a backup of your account with the AdWords Editor just in case things go wrong and you need to revert the changes, he advises.
And, be sure when using a script created by someone else, you don’t accidentally give them access to your data, cautions Vallaeys. Some scripts are designed to share results via email or a Google Sheet. The easiest way to check is to do a search for ‘@’ in the script code to see if someone else is included as a viewer in Google Drive or getting an email from the script, he says. You can then replace that person’s information with your own.
“Google has a great code editor that suggests what you can type next”, advises Vallaeys, “so don’t try to write code in some other editor, just write it in AdWords and let Google help you construct the code.” From the editor, it’s then easy to continue Previewing the script as you edit.

Troubleshooting: Checking What Has And Hasn’t Changed

Hammer points out that when a script runs, it will spit out a list of the changes it makes, but says he’s not a fan of the format. “There’s no real order, and it’s hard to tell what wasn’t changed.  A quick trick to monitor these changes is to use the AdWords editor.”

Here’s Hammer’s simple but sly trick for knowing what was and wasn’t changed by a script. First, make a backup or import the account before the script runs, and then re-import after it runs.  All of the changes will now be highlighted in green as “changes downloaded from AdWords”.

A bonus benefit, as Vallaeys also expressed, is that if it was too extensive or just plain wrong it’s easy to reject the changes, pause the script and go back to debugging.

how to tell what an adwords script changed

Use AdWords Editor to review what a script changed after it ran.

Advanced tip: Vallaeys applies a checks and balances approach to scripts designed for optimizing accounts. He says, “I usually split an optimization script into 2 parts: one part generates the suggestions, the other applies the approved changes. The way I approve the changes is through a Google Sheet by marking a ’1′ in a special column which the script can read.”

When To Use Scripts Or Ad Customizers

When Google introduced ad customizers in September, it took a lot of the pressure of to master scripts. Actually, now you can use ad customizers in scripts, but I’m not going to cover that here. In some ways ad customizers seem so simple compared to scripts, it feels like you might be cheating. (If you haven’t tried the new countdown widget in AdWords, check it out.)  I asked Vallaeys and Hammer how they decide when to use ad customizers versus scripts.

Vallaeys says that while Ad Customizers are extremely useful, they have the same shortcoming as any other part of the AdWords UI: “You get what Google gives you and you can’t customize it to your exact needs.” At Optmyzr they created  an Enhanced Script for AdWords (Create Ads From Spreadsheet) that uses the same principle as ad customizers but it also lets you generate keyword lists from the data in the spreadsheet. “That’s the beauty of Scripts, you can take a great idea and make it even better,” he says.

He adds that with a script, you can set up different ad templates depending on the data. A ticket broker could run a different ad template for concert tickets than for baseball tickets. “Scripts are excellent for easily generating tedious reports where you need to aggregate the data in a specific way. Calculating the account Quality Score used to take me half a day when I had to do it manually for a large account. Now a script does it for me automatically every day.”

Hammer admits that he probably uses scripts more often than necessary even though ad customizers are much easier to use. He points out that they automatically make the distinction between days left and hours left, so the complexity of this part of the logical code is gone for running countdown ads.

He says that from a high level, there are three things that push script usage: scale, repetition and dynamics. Here is Hammer’s rundown of when scripts or customizers are the better option.

Scale: Customizers and their ilk are designed for moderate scale or moderate control, not both. If you are targeting at the keyword level, it requires requires a virtual duplication of account structure to manage them. If you are frequently adding keywords, they’ll need to be added back to the business data that feeds customizers or default text here we come. Conversely, if it’s running only at the adgroup or even campaign level, customizers can be massively easier to use for large campaigns, but there’s a bit of loss of control.

Repetition: For the most part, customizers are designed for discreet times. Countdown customizers work great for sales that end at a specific date and time, or events that happen at a specific time. They don’t work well for things that happen every day at the same time, such as a same day shipping deadline or a store’s daily closing time.

Dynamics: – Text customizers are great for catalogs that don’t change too often. For example, text customizers work well when a company offers a number of models with different standard prices and specifications. They get much harder to use if that catalog is changing on a regular basis, as it might with a car dealer or antiques shop. For these kinds of businesses it’s usually much better to just use an inventory and a script rather than the business data format.

There’s also at least one special case that can only really be handled with a script, says Hammer. “Countdowns can only feed back dates and times with customizers. If you wanted your ad to read differently in the morning than night for some reason, that requires scripting. An example might be a lunch special that’s different than a dinner one.”

Customizers do offer the benefit of being able to use the user’s time zone and not the account’s preset one. “For retailers with consistent closing times, but national level presence this could be a powerful element,” says Hammer.

Start Experimenting

If you’re getting started with scripts and ad customizers, it can be a bit overwhelming and frustrating. With Scripts, I would recommend starting with reports only. Reports can’t do any damage to your account and editing them is much more straightforward than editing optimization scripts. Once you’re comfortable with your reporting and ecstatic about all the time you’re now saving, you can start to experiment with using scripts for management tasks.

Check out the resources list at the end of Part One of this series for sites, tutorials and people to follow. If you don’t have a programming background or time to fiddle around, don’t be shy about reaching out to a good developer. With a foundational understanding of what scripts and customizers can do, you can work with a developer to quickly get off the ground and start putting automation to work for you. Next up in our series will be tips for more advanced users.

The post AdWords Scripts For Every Level: Part 2, Intermediate Tips For Editing & Troubleshooting appeared first on Search Engine Land.