AdWords scripts are a powerful tool for making changes in your account. They can both alter entities in your account as well as make reporting a breeze. The main issue for most users is, what’s next? Sure the scripts you find from Google or others are useful, but they don’t always do exactly what you would like them too. This issue continually surfaces in questions and requests from both clients and users of our new service PPC Hero Pro.

The good news is that edits don’t have to be a harrowing ordeal. The bad news, without much experience, they can also be very scary the first few times you try. Besides learning JavaScript from the bottom up, one of the best ways to learn is to alter and make small tweaks to code that already exists. For the most part you can’t really break anything, if you are really worried Google has provided a preview tool.

Today we will be covering four relatively easy changes you can make to some of Google’s provided scripts. Each example is straightforward, not overly technical, and only requires editing a few lines of code.

Create a New Text Ad

This a quick solution that can speed up your workflow. It is super easy and is a good introduction.

What it does: Pretty straightforward, it automatically creates a text ad in the selected ad group.

What Can Be Changed: The example below adds an iterator that selects multiple ad groups and applies the ad to each one of those ad groups. Rather than selecting ad groups one by one, a single click applies the ads all at once. This can be done at the campaign level depending on your segmentation. If not you may have to use a labeling system or other identifier. We’ll cover labels in a bit.

function main() {
// Replace with a name of an campaign that exists in the account
var campaignName = “Campaign”;

var adGroupsIterator = AdWordsApp.Campaigns.withCondition(“Name = ‘” + campaignName + “‘”).adGroups()
.withCondition(“Name = ‘” + adGroupName + “‘”)

if (!adGroupsIterator.hasNext()) {
Logger.log(“Ad group ‘” + adGroupName + “‘ not found.”);
} else {
var adGroup =;

adGroup.createTextAd(“Ad headline”,
“First Line of description”,
“Second line of description”,
“”, // display url
“” // destination url

Adding Conversions to The Keyword Performance Report

What it Does:  This script breaks down all your keywords by average position and quality score. The metrics are summed across these categories, letting you see how your performance varies across position and quality score.

What Can Be Changed: What if you want conversions and conversion rates added to the report? This would allow you to see how these vary by position and quality score. By optimizing for quality score, are you really getting a worthwhile return? Similarly, the higher positions get many more clicks, are these clicks actually converting at a reasonable rate?

How to Do It: One thing you need to do is change the headings in the report. This can be done by adding two columns for conversions and conversions rates to the headers. Next, in the same section you need to define the number of headings. The default is 6, once you add the conversions data, you need 8.

header change

Next you need to add the new values to the map so the script has a way to store and manipulate them for output.


Next you’ll need to get the new data for each keyword, it will happen very similarly to the others fields. In the lines with if(data) simply include conversions like this.

data.totalConversions += stats.getConversions();

All you have to do now is to tell the script how to create the output. This is done by telling the script how to calculate conversion rate, which is very similar to the line that calculates CTR. Just divide the total conversions by the total number of clicks.

Now repeat the same steps for the PositionData segment in the second half of the script and you are done. If you are feeling adventurous and want to test your skills, try including CPA. One of the best perks of this exercise is that the keyword performance utilizes quite a few tools in the JavaScript arsenal and you can learn quite a bit breaking it down piece by piece.

Modified Campaign Copier

What it does: This script lets you select a campaign in your account and copy its contents.

What Can Be Changed: One simple change is taking advantage of labels to define what needs to be copied, allowing you to copy only the parts of a campaign you need.

By tagging the ad groups you want to move with the appropriate label, you can quickly move the parts you need, and only those, with minimal effort. You can also tell the script to remove the labels after it runs. This will allow you to pick up from where you left off in the event you hit your time limits (which can happen when working on very large accounts, with hundreds of thousands of entities).

How to Make the Changes: This is really easy.  Simply insert withCondition() into the var SourceAdGroups = to select which ad groups to copy. For this example I used the label ‘Copy’. This will pull all ad groups I’ve marked and place them in a new campaign.

You can use any label you want. You just have to make sure that you put it in the script. You can also place a line at the end of the function that copies the ad groups, and make the script to remove that label after copying by using the removeLabel() method. From there it is easy to also apply a new label so you know it has been completed.

Pause Ad Groups with Declining CTR

What it does: This script takes week over week performance from the last three weeks. If the ad group is below a certain CTR threshold and continues to decline, the script pauses those ad groups.

What Changed: This is useful for cleaning out the non-valuable ad groups, but what about other metrics that you consider in your optimization? For this example  I focused on conversions. I want to eliminate ad groups that continue to get traffic but are not getting conversions anymore.

How to Make the Changes: The first thing you have to do is create variables for the new metrics, cost and conversions. You can create a function for CPA. You can also just divide the variables without the function. If you want to get a little more advanced try setting a flagging system. For example you could set a true and false for CTR and Conversions and only pause the ad group if both have declined.

What Comes Next?

We’ve covered a lot today in a little bit of time. Hopefully this gets you started in the right direction in writing your own code. At the very least you can start making small tweaks without having to ask someone else. Remember if you ever get stuck, there are a lot of code examples out there. Similarly to learning by tweaking, you can find ways in which others solved similar problems and apply these solutions in your own work.

What ways have you edited existing code to make your PPC life easier? Let us know what you think about scripts or if there is just one problem you can’t seem to solve.

In the mean time feel free to check out PPC Hero Pro. Not only are there examples of the scripts we talked about today but some very cool apps for ad testing and keeping track of your historical quality scores.