An introduction to important javascript components, how to implement scripts, compatible integrations, tips, common mistakes, use cases, and free resources!
7. Comments
PAGE 7
Comments are notes that
are made within the
script that are not
executed. They are solely
for reference.
// This is a 1 line comment.
/* This is a multiple
line comment. */
8. Functions
PAGE 8
A function is a block of
code that is designed to
perform a particular task.
You’ll see the function
name followed by
parentheses. The code to
be executed is between
brackets.
function toCelsius(f) {
return (5/9) * (f-32);
}
9. Variables
PAGE 9
Variables are
containers for storing
data values.
Variables correspond
to objects and
entities.
Variables must be
identified with unique
names
var x = 5;
var y = 6;
var z = x + y;
x,y,z are variables
10. Objects
PAGE 10
Objects are variables but
can contain many values.
The contents of the
object are called
properties and each
property has a property
value.
Objects are sometimes
called elements.
var Shoes = {type:”Heels”,
color:”Red”, brand:”Prada”}
Property:
Type
Color
Brand
Property Value:
Heels
Red
Prada
11. Methods
PAGE 11
A method is a
property that contains
a function definition.
Can be used to call
information & make
commands.
http://www.w3schools.com/js/js_object_methods.asp
Object Properties
12. Selectors
PAGE 12
Selectors are used to
pull in the objects and
entitites that you have
identified in your
script.
Selectors can use
conditions, kind of like
filters.
var campaignSelector =
AdWordsApp.campaigns()
.withCondition("Clicks > 10")
.withCondition("Impressions > 100")
.orderBy("Impressions DESC")
.forDateRange("YESTERDAY");
13. Iterators
PAGE 13
Iterators are used to
pull in information in
phases, so as not to
overload the system.
An Iterator can be
used only after the
Selector has been
created.
20. @hoffman8 @heroconf #IntroToScripts
You don’t have to be able to write scripts in order to use them.
There are Tons of Free scripts at your disposal!
Examples from: FreeAdWordsScripts.com, Optimizyr Blog, Search Engine Land (courtesy of BrainLabs), and Developers.google.com
24. @hoffman8 @heroconf #IntroToScripts
7 Simple Steps
1. Navigate to the Script IDE in AdWords
2. Write (or Paste!) Your Script
3. Authorize the Script
4. Preview the Script
5. Review & Correct Errors
6. Run the Script
7. Schedule the Script
27. @hoffman8 @heroconf #IntroToScripts
Script IDE
PAGE
27
IDE = Integrated
Development
Environment
Allows for editing,
debugging, and
launching scripts
within the AdWords
interface
Slide 27
31. @hoffman8 @heroconf #IntroToScripts
Authorize
PAGE 31
Scripts may run on the user’s
behalf, when scheduled, even if
the user is not logged in.
Therefore, users must authorize
AdWords scripts to run and make
changes (as indicated in the
script).
33. @hoffman8 @heroconf #IntroToScripts
Check & Resolve Errors
PAGE 33
The log will show you where errors occur, so that you can
easily fix them. Be aware, though, that the line provided may
be code referencing a different line, where the actual issue
lies.
34. @hoffman8 @heroconf #IntroToScripts
Preview Again!
PAGE 34
After you’ve corrected the errors, preview your script again.
More errors may arise in later parts of the script. Rinse &
repeat until no errors arise.
35. @hoffman8 @heroconf #IntroToScripts
Run The Script
PAGE 35
Once errors have been
corrected, and the
preview is free of
errors, you’re ready to
run the script!
Just click the blue
button!
39. @hoffman8 @heroconf #IntroToScripts
GOOGLE SHEETS
& GOOGLE DRIVE
• Utilize Google Spreadsheets as a
data source. Ex:Add these keywords
• Export and Store Data
• Visualize Reports
• Create, Find, & Modify Files on
Google Drive
41. @hoffman8 @heroconf #IntroToScripts
EMAIL
• Receive a notification that the script
has ran.
• Receive an email with the script’s
findings.
• Utilize customize HTML to format
professional reporting to be
automatically sent to clients &
colleagues
42. @hoffman8 @heroconf #IntroToScripts
URL FETCHING
Make use of external data feeds:
• Pull in password-protected feeds
from your site (ex. Inventory
information)
• Pull information from alternate data
sources to inform script decisions
43. @hoffman8 @heroconf #IntroToScripts
JDBC
• Can connect your script to external
JDBC-compliant databases such as:
• Google Cloud SQL
• MySQL
• Microsoft SQL Server
• Oracle Databases
47. @hoffman8 @heroconf #IntroToScripts
When to Automate
PAGE 47
“…if you do something 2-3 times by
hand, the next time should be
automated.”
-Brad Geddes
@bgtheory
48. @hoffman8 @heroconf #IntroToScripts
Examples
PAGE 48
• Checking Ad Groups for the Number
of Keywords & Ads
• Checking for URL Errors
• Pulling Data for Frequent Reports
• Determining when Ad Tests Have
Reached Statistical Significance
• Bid & Budget Changes
• Ad Customizers
55. @hoffman8 @heroconf #IntroToScripts
• Javascript is case sensitive
• Be sure to utilize consistent capitalization
within naming conventions.
• Generally you’ll see the error
“undeclared” variable” if capitalization is
an issue
• Most sources suggest camel case
(firstName, lastName, etc)
Capitalization
57. @hoffman8 @heroconf #IntroToScripts
• If the error indicates the problem is in the last line,
there is probably one too many } brackets. Try
deleting it and previewing again.
• Semi-Colons should be used to end a line of
code, like a period to a sentence.
• A missing semi-colon will cause the script editor to
report an error but can cause the editor to identify the
wrong line
• Consistently use quotation marks. “ or ‘ can be
used but you must use the same to open and
close.
Grammar & Syntax
58. @hoffman8 @heroconf #IntroToScripts
• Make sure that you clear out the IDE, if necessary.
• Common error message: “scripts must have one main
function”
• Be sure to update all the customized data to fit
your needs.
• Date, Email/Spreadsheet URL, Currency, etc.
Borrowed Scripts
59. @hoffman8 @heroconf #IntroToScripts
• Scripts that have specific date ranges
should not be scheduled
• Never ‘set it and forget it’ with a script that
implements changes.
Logistics
65. Smart People.
• Russell Savage, FreeAdWordsScripts.com @russellsavage
• Steve Hammer, Rank Hammer @armondhammer
• Dan Gilbert, Brainlabs @brainlabs
• Frederick Vallaeys, Optimyzr @siliconvallaeys
• Jon Gritton, Cobnut Web Services google.com/+JonGritton
• Christi Olson, iSEM Consulting @ChristiJOlson
• Scripts Forum
Follow The Smart People.
66. @hoffman8 @heroconf #IntroToScripts
Thank You!
CLIX Marketing
217 La Grange Rd
Pewee Valley, KY
40056
Tel :502.442.2776
Fax :502.805.0643
Web: clixmarketing.com
66
@clixmarketing
@hoffman8
Facebook.com/
clix-marketing
amy@clixmarketing.com
Notas del editor
All JavaScript variables must be identified with unique names.
These unique names are called identifiers.
Identifiers can be short names (like x and y), or more descriptive names (age, sum, totalVolume).
The general rules for constructing names for variables (unique identifiers) are:
Names can contain letters, digits, underscores, and dollar signs.
Names must begin with a letter
Names can also begin with $ and _ (but we will not use it in this tutorial)
Names are case sensitive (y and Y are different variables)
Reserved words (like JavaScript keywords) cannot be used as names
All JavaScript variables must be identified with unique names.
These unique names are called identifiers.
Identifiers can be short names (like x and y), or more descriptive names (age, sum, totalVolume).
The general rules for constructing names for variables (unique identifiers) are:
Names can contain letters, digits, underscores, and dollar signs.
Names must begin with a letter
Names can also begin with $ and _ (but we will not use it in this tutorial)
Names are case sensitive (y and Y are different variables)
Reserved words (like JavaScript keywords) cannot be used as names
All JavaScript variables must be identified with unique names.
These unique names are called identifiers.
Identifiers can be short names (like x and y), or more descriptive names (age, sum, totalVolume).
The general rules for constructing names for variables (unique identifiers) are:
Names can contain letters, digits, underscores, and dollar signs.
Names must begin with a letter
Names can also begin with $ and _ (but we will not use it in this tutorial)
Names are case sensitive (y and Y are different variables)
Reserved words (like JavaScript keywords) cannot be used as names
All JavaScript variables must be identified with unique names.
These unique names are called identifiers.
Identifiers can be short names (like x and y), or more descriptive names (age, sum, totalVolume).
The general rules for constructing names for variables (unique identifiers) are:
Names can contain letters, digits, underscores, and dollar signs.
Names must begin with a letter
Names can also begin with $ and _ (but we will not use it in this tutorial)
Names are case sensitive (y and Y are different variables)
Reserved words (like JavaScript keywords) cannot be used as names