advanced adwords scripts: harder, better, faster, stronger by russell savage
TRANSCRIPT
#SMX #23C1 @russellsavage
June 3rd, 2015 – SMX Advanced - Seattle
ADVANCED ADWORDS SCRIPTS: HARDER, BETTER, FASTER,
STRONGER
#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
▪ 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
▪ 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
▪ 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
▪ 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
▪ 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
▪ Your API calls need to retry ▪ Always sleep
between retries
Fortify Your Code Against API Errors
#SMX #23C1 @russellsavage
▪ Until AdWords Scripts has better alerting
Be Notified When Your Script Fails
#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
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
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