Advanced AdWords Scripts: Harder, Better, Faster, Stronger By Russell Savage

37
#SMX #23C1 @russellsavage June 3 rd , 2015 – SMX Advanced - Seattle ADVANCED ADWORDS SCRIPTS: HARDER, BETTER, FASTER, STRONGER

Transcript of Advanced AdWords Scripts: Harder, Better, Faster, Stronger By Russell Savage

#SMX #23C1 @russellsavage

June 3rd, 2015 – SMX Advanced - Seattle

ADVANCED ADWORDS SCRIPTS: HARDER, BETTER, FASTER,

STRONGER

#SMX #23C1 @russellsavage

Apologies to…

#SMX #23C1 @russellsavage

▪ Faster ▪ Find slow code and speed it up

▪ Better ▪ Make your code easier to reuse and debug

▪ Stronger ▪ Know when errors happen and recover gracefully

▪ Harder ▪ Do cool stuff

Agenda

#SMX #23C1 @russellsavage

▪ Russ Savage ▪ Systems Architect @

▪ FreeAdWordsScripts.com

About Me

#SMX #23C1 @russellsavage

Faster

#SMX #23C1 @russellsavage

▪ Available at Adwords Scripts Developer Page ▪ https://goo.gl/BkWJXn

▪ Pay close attention to ▪ Use IDs for filtering ▪ Don’t run selectors in a

tight loop ▪ Batch changes

Follow Best Practices

#SMX #23C1 @russellsavage

Some Slow Code

#SMX #23C1 @russellsavage

Some Slow Code

#SMX #23C1 @russellsavage

Profiling Your Code

#SMX #23C1 @russellsavage

Some Slow Code Profiled

#SMX #23C1 @russellsavage

Some Slow Code Profiled

#SMX #23C1 @russellsavage

Some Slow Code Profiled

#SMX #23C1 @russellsavage

Some Slow Code Profiled

#SMX #23C1 @russellsavage

Some Faster Code Profiled

#SMX #23C1 @russellsavage

Some Faster Code Profiled

#SMX #23C1 @russellsavage

Some Faster Code Profiled

40%

#SMX #23C1 @russellsavage

▪ Use best practices ▪ https://developers.google.com/adwords/scripts/docs/best-practices

▪ Use a profiler to find slow code chunks ▪ Develop your own or use mine ▪ https://goo.gl/Uu9UYI

▪ Pareto principle ▪ 80% of the slowness comes from 20% of the code

Faster Summary

#SMX #23C1 @russellsavage

Better

#SMX #23C1 @russellsavage

▪ Pick a JavaScript coding style & stick with it

▪ If possible, convert copied code to your style

▪ Helps when finding issues and debugging

▪ I use Google’s (mostly)

Have Some Style

#SMX #23C1 @russellsavage

Sample From Google’s Style Guide

#SMX #23C1 @russellsavage

▪ Use functions and classes to: ▪ Avoid writing the same code twice ▪ Document complicated code ▪ Make code more portable for reuse

Functions and Classes

#SMX #23C1 @russellsavage

Documenting Complicated Code

Why would anyone have this code?

#SMX #23C1 @russellsavage

▪ Pick a coding style and stick with it ▪ Use functions an classes to document

complicated code ▪ For reusable classes, check out my ▪ Salesforce Class - http://goo.gl/GvvbYd ▪ Twilio Class - http://goo.gl/1hK2xM

Better Summary

#SMX #23C1 @russellsavage

Stronger

#SMX #23C1 @russellsavage

▪ Your API calls need to retry ▪ Always sleep

between retries

Fortify Your Code Against API Errors

#SMX #23C1 @russellsavage

Fortify Your Code Against API Errors

#SMX #23C1 @russellsavage

▪ Until AdWords Scripts has better alerting

Be Notified When Your Script Fails

#SMX #23C1 @russellsavage

Be Notified When Your Script Fails

#SMX #23C1 @russellsavage

▪ Add checksums to your code

Watch Out For Altered Code

#SMX #23C1 @russellsavage

Watch Out For Altered Code

Probably better to store checksums somewhere else…

#SMX #23C1 @russellsavage

▪ Always retry external API calls ▪ Write scripts so that you are notified when

they fail ▪ Watch out for co-workers changing your

code

Stronger Summary

#SMX #23C1 @russellsavage

Harder

#SMX #23C1 @russellsavage

Generate Tasks from Scripts

https://developers.google.com/adwords/scripts/docs/examples/google-tasks

#SMX #23C1 @russellsavage

Send Data to mySQL Database

https://developers.google.com/apps-script/guides/jdbc

#SMX #23C1 @russellsavage

Machine Learning with Prediction API

http://selnd.com/1DnVksj

#SMX #23C1 @russellsavage

AdWords Scripts is truly becoming a viable alternative to the API for most users

This is still just a fraction of what you can do

#SMX #23C1 @russellsavage

THANK YOU!

@RussellSavage

FreeAdWordsScripts.com

Join us @SMX East NEW YORK CITY

Sept. 29th – Oct. 1st 2015