5 Easy Ways to Customize AdWords Scripts
January 13, 2015
Find AdWords Scripts a bit scary? The truth is any computer savvy person can edit and customize AdWords Scripts. Not a coder? Not a problem.
Most scripts are very detailed and vetted by loads of users, but sometimes you need to tweak them to meet your very specific needs.
If you’re just getting started with adding a script to your account this quick tutorial at the bottom of this post will guide you.
You don’t need to know a lot before we start, but you should checkout the layout of a script by Daniel Gilbert. It always helps me to understand how something works by working through a short example and using it.
- Function: A function contains code between two curly brackets.
- Variable: A variable contains information which can be accessed at a later point in time.
- String: A string is information in the form of text wrapped in quotation marks.
- Parameter: A parameter is information in the form of a variable such as a date range, number, and so on.
- Object: An object is a collection of variables and functions contained between two curly brackets. The object pointed to in the picture, MailApp, is one of the many objects that comes ready-made in AdWords.
- Method: When a function is contained within an object, it is known as a method. From the picture: the sendMail method is one of the functions belonging to the MailApp object.
Still with me? It gets easier. Trust me.
1) Using variables in a script.
You can name a variable anything you want. As long as it makes sense to you it doesn’t really matter. What’s important is that the information (or String) the variable contains is correct and referred to correctly in the object.
var recipient = “email@example.com”;
var subject = “Scripts are my jam”;
var body = “Information you want to share.”;
MailApp.sendEmail(recipient, subject, body);
You can change (recipient, subject, body) to (email, emailaddress, useremail) and the MailApp object works exactly the same only the variable names have changed. You can even add a variable. Just remember to add the variable name to the object.
var email = “firstname.lastname@example.org”;
var subjectline = “It’s kind of sad scripts are my jam”;
var emailbody = “Information you want to share within the email body.”;
var secondemailbody = “Other information you want to share.”;
MailApp.sendEmail(email, subjectline, emailbody, secondemailbody);
2) Removed Pause and Deleted Ads
If want to remove certain types of ads in a script you simply set the status to ENABLED in your script and paused or deleted campaigns are filtered out.
var campaignStatus = (“Status = ENABLED”);
You want to make sure to add the above line before the line that contains the iterator like keywordIterator or campaignIterator. Then below the iterator line add the campaign status .withCondition(campaignStatus) line.
var keywordsIterator = AdWordsApp.keywords()
The campaign status is now set to filter paused and deleted. You can change the campaign status to ENABLED, PAUSED, or REMOVED.
3) Adding a Metric
Adding a metric is simple. Typically metrics are added below the iterator that has .next() added to the iterator. Here is a list of metrics you can add – AdWords Developer.
var keyword = keywordsIterator.next();
var cost = stats.getCost();
var avgcpc = stats.getAverageCpc().toFixed(2)*100/100; //fixed to 4 decimal places
var avgposition = stats.getAveragePosition();
Below you’ll see an area for Keys, Rows, and Wraps. Be sure to add your variable name to Keys and Rows, then add another “True” in Wraps.
In my next scripts post I’ll discuss how to manipulate the spreadsheet when adding metrics.
4) Conditions and Limits
Below the iterator you can add conditions and limits to your script. Here are few examples:
var keywordsIterator = AdWordsApp.keywords()
//You can change the number from “0” to any number.
.withCondition(campaignStatus).withCondition(“Impressions > 0”)
.withCondition(“Conversions = 0”)
.orderBy (“Clicks DESC”)
5) Date Ranges
You’ll notice the last line above contains the parameter “timerange.” That’s because the time range was set very early on in the script. Normally in the first 10-20 lines. Timerange is then referred to later on in the script in one or more places.
var timerange = ‘LAST_30_DAYS’;
You can select a time ranges from any of the following options: TODAY, YESTERDAY, LAST_7_DAYS, THIS_WEEK_SUN_TODAY, LAST_WEEK, LAST_14_DAYS, LAST_30_DAYS, LAST_BUSINESS_WEEK, LAST_WEEK_SUN_SAT, THIS_MONTH, LAST_MONTH, ALL_TIME.
I hope you found this helpful! This is by no means an exhaustive list of things you can change within AdWords Scripts or uses exact coding terminology, it’s simply meant to be an introduction for those interested in tweaking scripts without having to rely on a programmer. Good luck scripting!
Browse By Category
Your Guide to Getting Organized for PPC Success
Organization is key to success in the PPC industry. Here is a guide to organizing your space, time, resources, and workload for efficient PPC management.
A Reminder About Work-Life Balance
Proper Work-Life Balance Is Something Easily Forgotten. Here Is A Reminder That It's Okay To Have A Life Outside Of Work & Constantly Checking Performance.
A bi-weekly newsletter packed full of resources and strategies that will help make you a better PPC expert.
Hanapin Marketing | The PPC Agency of Experts Behind PPC Hero
The Advertising Principles That Guide Facebook's Decisions
Facebook highlights the advertising principles that guide their decision making in response to recent events.
Smart Ways to Get More Marketing Budget and Better Tools
In this new live webinar, Kristin Vick from Hanapin Marketing and Jeff Sauer from Jeffalytics discuss how marketers can ensure they have the budget they need to be effective with online advertising and get the right tools to make that argument.
The Hero Conf Difference
Of the 50+ search and social conferences you can choose from, we're here to show you why Hero Conf is a can't miss event for busy digital marketers like you.