In theory, AdWords Scripts can be a big time saver by automating tedious optimizations like maintaining an alpha-beta account structure and SKAGs, or running complex reports like those that calculate account level Quality Score. But what I found in practice when using Scripts is that any time saved can easily be eaten up by the tasks involved with maintaining the code across multiple accounts. Luckily Google has made huge strides in making it easier to run the same script across accounts in an MCC but there are still a few useful tricks that may help you save time when running your scripts.
MCC AdWords Scripts
The easiest way to run the same script in more than one account is to place the code in the MCC account rather than in individual accounts. In addition to only maintaining a single copy of the code, it has the benefit of hiding it from your clients so that they can’t copy it and cut you out of the picture. Also, and perhaps more importantly, they can’t accidentally break things while experimenting with your code. Remember that Scripts can make changes in an account so the last thing you’d want is to accidentally change all the bids to the wrong value.
Until recently the drawback of MCC Scripts was that there was no easy way to do slightly different things in each account, but now there is an easy solution for this that involves passing the variables as an argument in the MCC code. I’ll explain this in the next section.
Variable Inputs With The String Argument
When you manage multiple accounts, chances are you want to do slightly different things in each account. One of the simplest examples is that you send an email with results to different people. In programming, we can use variables to store these different settings while the underlying code can remain the same. Obviously this is more efficient than maintaining several different copies of the code where there are only minimal differences.
Recently Google enabled passing variables for MCC-level AdWords Scripts through an optional argument string. This means that we can set up a variable with different values for different accounts and then pass this to the Script for execution in individual accounts.
Download a working example of this technique in my script that enables cross account negative keywords.
While this is exactly what programmers need, the special notation may scare off non-programmers, and for those that do try, it can be prone to errors. The risk is that a small error made in the code by a non-programmer, something as mundane as leaving out a comma can break the entire code, causing it to not work properly in any of the accounts in an MCC.
Tip 1: Put Variable Inputs In A Google Sheet
A safer way for non-programmers to provide the different values for the variables is by placing them in a Google Spreadsheet. That way you can use the UI of Sheets to give users dropdowns and even do error checking on their inputs. From the programmer’s perspective, there is some additional work involved in writing the code to connect to the Google Sheet and fetch the inputs.
Here is the sample code for using settings from a remote sheet and a sample Google Sheet with variables.
Choosing Between Executing A Script In Parallel Or In Series
When running a Script in an MCC account you have two options for the order in which accounts are processed: sequentially (in series) or in parallel. When you work on accounts in series, you can specify the order in which they are processed. This can be very useful, for example when one company has multiple accounts where you don’t want a script to accidentally add duplicate keywords so you need to know when a keyword was added before starting work on the next account. However, the big limitation in this scenario is that your script will timeout after 30 minutes which may not give it enough time to complete all its work.
You can also process the accounts in parallel, which means that the Script starts working on all accounts at the same time. This is great when the work done in one account has no impact on what you do in another account, a common scenario if all the accounts are for different clients. The big benefit here is that the script gets the full 30 minutes in every account it touches. There’s even an additional 30 minutes at the end during which a callBack function gets to collate all the results obtained from work done in the individual accounts.
But there is a limit of 50 accounts that can be processed in parallel and that’s often not enough so here’s my second tip for becoming more efficient with MCC AdWords Scripts.
Tip 2: Run Scripts In More Than 50 Accounts
When operating on accounts in parallel, Google limits this action to 50 accounts at a time. And because many scripts take several minutes to finish, running them in series is not the solution either so you have to use some tricks to get all the work done.
One solution is to label the accounts in your MCC in groups of no more than 50. For example, apply the label ‘automotive’ to 40 accounts and ‘consumer electronics’ to 30 others and then create two copies of the same script. In the first script your account selector calls the automotive accounts and in the other script it calls the consumer electronics accounts.
Another approach comes courtesy of Alex Wang from the team that builds AdWords Scripts at Google. He created some code that applies labels to accounts that have already been processed.
This approach allows you to process up to 1,200 accounts per day (50 accounts * 24 hours = 1,200 accounts per day) if you schedule it to run hourly.
Tip 3: Store Script Code Remotely And Use Eval()
In cases where you maintain multiple copies of the same script, a big downside is that even small updates to your code (like when you’re making improvements) requires making that same change in many places. This is where the eval function can come in handy. It allows you to call a remotely hosted piece of code for inclusion in the script. The code you place in AdWords is a generic wrapper which calls the code it needs to do its work from a remote location, for example, an Amazon Elastic Cloud server.
Here is what that looks like for the same code I showed to use remote variables. In that same spreadsheet there are columns to specify the location of the remote script.
Here is the code you can try out yourself using eval to get the script remotely.
Those are some of the advanced AdWords Scripts tricks I’ve learned over the years to make working with Scripts more efficient when dealing with many accounts. We’ve also created a nice graphical user interface that simplifies this even more in Optmyzr’s Enhanced Scripts. But if you’re ready to roll up your sleeves and start programming yourself, I hope these tips will help you.