Skip to content
Search engines 5511dd3

Google AdWords Scripts Offers Enhanced Automation

Jeff Shjarback

This YouMoz entry was submitted by one of our community members. The author’s views are entirely their own (excluding an unlikely case of hypnosis) and may not reflect the views of Moz.

Table of Contents

Jeff Shjarback

Google AdWords Scripts Offers Enhanced Automation

This YouMoz entry was submitted by one of our community members. The author’s views are entirely their own (excluding an unlikely case of hypnosis) and may not reflect the views of Moz.

In the world of PPC marketing, it’s important to know what’s going on at all times. Whether you are just getting started with pay-per-click marketing or you have been doing it for years, you know that the main goal is to make money or get the proper ROI for your clients. The problem is that technology can often stand in the way of generating the ROI you like because it can be hard to analyze and manipulate the data quickly and efficiently. This is where AdWords Scripts comes into play.

Discover the Benefits of Using AdWords Scripts

For those that manage PPC accounts, there are never enough hours in the day complete all your tasks such as checking for 404 errors, pausing ads with low click-through-rates, bidding up keywords with high quality scores, testing new ad copy, etc. Until fairly recently, managing all these tasks without powerful automation software platforms such as Kenshoo or Marin was very difficult for small or medium sized business owners/marketers. Now with AdWords scripts you can easily find scripts or create them yourself to help automate your most important and time consuming tasks.

Learning to use scripts can really help put the wind in the sails behind your AdWords account and allow you to focus on other facets of your marketing campaign or small business. There is, however, a couple minor disadvantages with AdWords scripts. The first, you may need to understand or learn a little more about coding and programming. Don't be intimidated, however, because in this article I will provide you with a lot of great resources that have already written the code/scripts for you. You just need to understand how to implement the code in your account. You will also need a suitable MCC AdWords account then you will have to apply via the AdWords API center to get access.

The second minor drawback is that AdWords scripts can only communicate with 100,000 items every time a script runs. If you are managing an AdWords account for a medium or larger sized business that has over 100,000 keywords than it may be time to upgrade to some of the PPC software I mentioned above. For the smaller accounts, learning some of the fundamentals about AdWords Scripts will be your ticket to easy street.

Scripts are able to communicate with external data sources such as your emails, account alerts, spreadsheets, documents and research data from numerous URLs. AdWords Scripts give users the ability to work directly with Google AdWords API and extract data in Google Spreadsheets, or in similar data software. Scripts are not only useful, but they save time even for things as simple as adding charts to a spreadsheet, generating statistics and reports. The data can then be sliced and diced in whatever fashion you deem most appropriate for execution of your marketing strategy.

How to Write AdWords Scripts

AdWords scripts provide users with the convenience and advantage of programming access to AdWords data by writing simple JavaScript in an IDE that's then embedded directly into your web application. For those of you that are unfamiliar with the term IDE, it stands for Integrated Development Environment and is a software program that compiles source code into an executable program that helps to run scripts and build software automation tools.

Take advantage of the Google interface that makes it much easier to write scripts since the IDE indents and colors your code with the available functions that are featured in a drop down menu. It's up to you to determine the script execution schedule based on your specific needs — it can be set every hour, once a week, or any schedule that works best for you.

Make The Bots Work For You

Codes/Scripts are Applicable for:

  • Ad Performance Reviews
  • Keyword Performance Reviews
  • Quality Score Tracking
  • Make Quick Changes across multiple ad groups or keywords
  • Change a Bid across multiple ad groups or keywords
  • Check for Broken Landing Page Links (404 Errors)
  • Ad Creative Test Automation
  • Finding Anomalies in Keywords, Ad Groups and Ads
  • Merge Labels From Multiple Campaigns
  • Maximize your external inventory data to either make changes to bids or to pause and restart keywords
  • Increase decision making efficiency when it comes to changing keywords, or group ad bids by using your stat trends over a several week period for better results

AdWords Scripts may be a new learning curve, but it's definitely worth the time and effort. AdWords Scripts has always been a somewhat neglected feature of the advertising program because it requires a decent amount of JavaScript knowledge. As a result, some users are not able to produce the scripts they need, to know what’s going on within a particular segment of the campaign. However, there are a lot more resources now in place to help individuals with little coding knowledge to utilize AdWords Scripts for their accounts and a lot of them will be provided for you in this post.

There are a lot of benefits to having scripts in place. For example, you can get an ad performance review about all of the ads you have across the Internet. You will get statistics as well as the destination URL in a report. Depending upon how you like to analyze your data, you can even choose to have the report sent to you in an Excel document – which requires creating a seed document.

You can also have a keyword performance report. If you don’t know what keywords are working for you and which ones are not, you’re going to be dead in the water in no time at all. You need to be using the right keywords and targeting appropriately for your client and their market. As soon as you view a report to show you which ones are not working for you, it’s imperative that you receive these reports often. So you can make the appropriate changes within a particular campaign that you are running (and paying for) in a timely fashion.

Using Scripts for Enhanced Automation

With JavaScript, you don’t have to do all of the report pulling on your own. You can have the data go into a document on your Google Drive. Or you can have a report sent to you. The point is that the scripts put the data in your hands automatically, so you don’t have to make a conscious effort to go and retrieve it.

The problem lies with the fact that JavaScript can be difficult for some and that most people don’t know how to use it effectively in AdWords Scripts.

Google AdWords has now made it easier for everyone. The scripts don’t have to be advanced. All it takes is simple JavaScript in an IDE and it gets embedded directly in the web application. What’s great about it is that they can be scheduled to be executed as you determine – as frequently as every hour. The scripts are going to help you access all of the major components of AdWords. This includes campaigns, ad groups, ads, keywords and even AdParams and labels.

If you’re not sure about JavaScript, you don’t necessarily have to be the one to write the script on your own. You just have to be willing to try out the concept. There are plenty of communities where you can find script that has been written and tested by others. They will share their scripts and tell you what you need to do to be able to use it in your own Google AdWords account.

Some of the Top Web Resources for Learning or Implementing AdWords Scripts:

Everyone in Digital Marketing, regardless if they have experience in SEO or PPC has had to deal with either fixing or locating broken URLs or 404 errors. Here is a quick sample AdWords script you can use to report on any broken URLs/Landing pages in your account. You can also easily add any other error codes to check for, by adding them to the BAD_CODES array at the beginning of this script.

Report on Broken URLs In Your Account:

/****************************
* Find Broken Urls In Your Account
* Version 1.1
* ChangeLog v1.1
*  - Updated to only see Text Ads
* Created By: Russ Savage
* FreeAdWordsScripts.com
****************************/
function main() {
  // You can add more if you want: http://goo.gl/VhIX
  var BAD_CODES = [404,500];
  var TO = ['[email protected]'/*,'[email protected]'*/];
  var SUBJECT = 'Broken Url Report - ' + _getDateString();
  var HTTP_OPTIONS = {
    muteHttpExceptions:true
  };
  //Let's look at ads and keywords for urls
  var iters = [
    //For Ad Level Urls
    AdWordsApp.ads()
      .withCondition("Status = 'ENABLED'")
      .withCondition("AdGroupStatus = 'ENABLED'")
      .withCondition("CampaignStatus = 'ENABLED'")
      .withCondition("Type = 'TEXT_AD'")
      .get(),
    //For Keyword Level Urls
    AdWordsApp.keywords()
      .withCondition("Status = 'ENABLED'")
      .withCondition("DestinationUrl != ''")
      .withCondition("AdGroupStatus = 'ENABLED'")
      .withCondition("CampaignStatus = 'ENABLED'")
      .get()
    ];
  var already_checked = {};
  var bad_entities = [];
  for(var x in iters) {
    var iter = iters[x];
    while(iter.hasNext()) {
      var entity = iter.next();
      if(entity.getDestinationUrl() == null) { continue; }
      var url = entity.getDestinationUrl();
      if(url.indexOf('{') >= 0) {
        //Let's remove the value track parameters
        url = url.replace(/\{[0-9a-zA-Z]+\}/g,'');
      }
      if(already_checked[url]) { continue; }
      var response_code;
      try {
        Logger.log("Testing url: "+url);
        response_code = UrlFetchApp.fetch(url, HTTP_OPTIONS).getResponseCode();
      } catch(e) {
        //Something is wrong here, we should know about it.
        bad_entities.push({e : entity, code : -1});
      }
      if(BAD_CODES.indexOf(response_code) >= 0) {
        //This entity has an issue.  Save it for later.
        bad_entities.push({e : entity, code : response_code});
      }
      already_checked[url] = true;
    }
  }
  var column_names = ['Type','CampaignName','AdGroupName','Id','Headline/KeywordText','ResponseCode','DestUrl'];
  var attachment = column_names.join(",")+"\n";
  for(var i in bad_entities) {
    attachment += _formatResults(bad_entities[i],",");
  }
  if(bad_entities.length > 0) {
    var options = { attachments: [Utilities.newBlob(attachment, 'text/csv', 'bad_urls_'+_getDateString()+'.csv')] };
    var email_body = "There are " + bad_entities.length + " urls that are broken. See attachment for details.";
    for(var i in TO) {
      MailApp.sendEmail(TO[i], SUBJECT, email_body, options);
    }
  } 
}
//Formats a row of results separated by SEP
function _formatResults(entity,SEP) {
  var e = entity.e;
  if(typeof(e['getHeadline']) != "undefined") {
    //this is an ad entity
    return ["Ad",
            e.getCampaign().getName(),
            e.getAdGroup().getName(),
            e.getId(),
            e.getHeadline(),
            entity.code,
            e.getDestinationUrl()
           ].join(SEP)+"\n";
  } else {
    // and this is a keyword
    return ["Keyword",
            e.getCampaign().getName(),
            e.getAdGroup().getName(),
            e.getId(),
            e.getText(),
            entity.code,
            e.getDestinationUrl()
           ].join(SEP)+"\n";
  }
}
//Helper function to format todays date
function _getDateString() {
  return Utilities.formatDate((new Date()), AdWordsApp.currentAccount().getTimeZone(), "yyyy-MM-dd");

How to Make Sure You Don't Screw Up

So far, we have learned that Scripts are really cool and can you help you a lot in AdWords Management. However, with that, there can also be complexities when dealing with enhanced automation and robots, just ask our friend, Morpheus, all about that when you get a chance. To all those that are reading this, remember, you are the one. Anyway, what if you were to increase bids on all keywords in your account 300% instead of 30%? One extra zero in your coding script and this could easily happen and most of the time the results would not be that pretty.

A Couple Ways to Prevent Errors from Happening:

  1. Review all proposed changes before they are made and fully implemented. The preview function in AdWords scripts will let you run your script briefly for about 30 seconds so you can see how it is affecting and making changes to your account without having it change your entire account.
  2. Create a small dummy account / campaign / ad group or use an older non-functioning paused account and run the script on the dummy campaign / ad group first to make sure it is working properly and implementing the functionality you were looking for.

"What If I Told You, Robots Can Find The Anomalies In Your Keywords, Ads and Ad Groups?"

Keeping Up With The Rapid Pace Of Technology

Does this mean we are getting closer to the Singularity of Man? That would be a better question for Ray Kurzweil of Google, than me, but it is amazing how fast the technology industry is advancing in such a short time period. Even within the AdWords technology, we are seeing rapid increases and much of it has to do with people understanding Scripts more extensively to allow for more automation within your campaigns. It allows you to set up rules that will do what you want, when you want it. Don’t have the time to change one thing in all of your ads? No problem, you can create a script that will run the changes for you. It’s kind of like macros on steroids – and with the ability to schedule when the macros run, so you don’t even have to push a button.

Especially, when it comes to some of your larger ad campaigns, you have to figure out the proper strategies to get ROI on your AdWords campaigns for the clients. You may know a lot about SEO and PPC, but if you don’t know about scripts, you are missing out on a huge opportunity to make your life easier.

Enhanced automation can save you hours every week – and put more money into your pocket or your clients pocket by ensuring that your campaigns are running smoothly. Want to get by the hour updates? Want to find out what you need to do within the last few hours of a campaign? Writing a script will ensure you get what you need – and then it’s up to you to determine what you are going to do with the data.

If you are already using the Google AdWords advertising functions, it’s advantageous to use the scripts because it will allow you to control what’s going on more effectively. And if you don’t want to write the scripts on your own, there are plenty out there that you can “borrow.” Let me know if you find any other useful scripts or ways to automate your PPC Marketing campaigns.

Back to Top
Jeff Shjarback
Jeff Shjarback is a Digital Marketing Consultant, Writer and Blogger that enjoys blogging about online marketing, small business, lead generation, economics, innovation & emerging technology, future trend analysis and business philosophy.

With Moz Pro, you have the tools you need to get SEO right — all in one place.

Read Next

The Ultimate SEO and PPC Integration Playbook — Whiteboard Friday

The Ultimate SEO and PPC Integration Playbook — Whiteboard Friday

Jun 07, 2024
Use Google Ads AI & Machine Learning To Run Better Campaigns

Use Google Ads AI & Machine Learning To Run Better Campaigns

Jul 26, 2023
How to Use Keywords to Combine the Power of SEO and Google Ads [Case Study]

How to Use Keywords to Combine the Power of SEO and Google Ads [Case Study]

Jul 19, 2022

Comments

Please keep your comments TAGFEE by following the community etiquette

Comments are closed. Got a burning question? Head to our Q&A section to start a new conversation.