PPC toolkit expands with Bing Ads Scripts’ cross-account operations

Columnist Frederick Vallaeys offers code samples for sending email and creating virtual labels with JSON to fill in some missing pieces.

Chat with SearchBot

Bing Ads app icon on mobile device

Bing Ads announced they now have scripts which can automate tedious and repetitive work just like advertisers have been doing with Google Ads Scripts. And it’s even possible to paste scripts from Google into Bing Ads where the system will automatically change the code as needed to work in Bing. But because the Bing capabilities are brand new and still in beta, there are a few things you should know before getting started.

Specifically, there is no support for email, labels or spreadsheets. So while we can automate some very useful stuff, there is no way to monitor the automation. And as I’ve written about before on this blog, monitoring automation is one of the key roles humans will play as automation in PPC becomes more widespread.

If we have to monitor our automation by manually looking at logs as the code is running, we won’t really save much time but luckily Bing has provided support for UrlFetch which means we can build the missing pieces of the puzzle and I’ve done that here for you. So take a look at the code samples for sending email and creating virtual labels with a JSON data store at the end of the post. There’s even a technique for sending the data to Google Sheets.

A unique Bing capability: Automate across accounts

Out of the gate, scripts for Bing work at the MCC and single account level. When working with an MCC script, you can execute a function in up to 50 accounts in parallel with the executeInParallel() function. Just like with Google Ads, this means you can run a common task in up to 50 accounts at once.

But one nifty thing that appears to be new and exclusive to Bing Ads is that you can switch back and forth between accounts using the MCC app and then do some work in the selected account. This is interesting because it makes cross-account operations much easier, something that should be of interest to larger advertisers who maintain multiple accounts for the same business.

Image showing an example of Bing Ads Script

For example, you could find the best performing ad headline in one account and then add that to new ads in another account. This is technically also possible with parallel execution but it’s just a bit simpler to code up in Bing. And given that there are many marketers with limited coding experience dabbling with scripts, anything that makes it easier to write code is a welcome improvement.

What Bing Ads scripts can do

Bing scripts are adding new capabilities several times a month but for now they still trail what you can do with Google’s Ad Scripts. In terms of supported ads-related entities, here’s what Bing currently covers:

  • Accounts
  • Campaigns
  • Ad Groups
  • Keywords
  • Ads
  • Bids
  • Budgets

With this functionality, you can get stats for the most common entities and make automated optimization decisions like what should be paused because it’s performing poorly. You can change bids based on promotions, or you could shift budgets between campaigns based on performance.

Budget scripts are very popular based on my experience with my company, Optmyzr, and Bing Ads Scripts can handle some of the most frequent use cases out of the box. For instance, evaluating budgets in ways that closer reflects how typical businesses think about budgets, i.e., monthly account level budgets rather than campaign daily budgets.

There are some notable things that are not yet supported by Bing Ads scripts:

  • Search Terms
  • Reports
  • Ad Extensions
  • Labels
  • Display
  • Shopping

While it’d be great to get support for extensions, different campaign types, and search terms management, we can still build many other useful scripts while we wait for these. However, not having labels and reports is a bit more limiting because these capabilities have been instrumental in writing better scripts, even for the entities that are supported.

Working without reports

So what do these limitations mean in terms of what you can expect to do today? Because we can’t use reports, we are limited to just the stats that are supported through the stats object and while that includes the most important ones like clicks, impressions, cost, conversions, etc., it’s not the full list of everything. Here is a list of the stats currently supported:

Stats In Bing Ads

Many scripts I’ve written rely on reports to pull stats because it’s faster and works better for very large accounts. Because Bing Ads Scripts have limits similar to those of Google and can only pull 50,000 entities in iterators and 250,000 entities per script execution, analyzing an account with 250,001 keywords won’t work for now unless you do some serious workarounds that store temporary data after each script execution.

Working without labels

Because labels are not supported, it’s harder to build workflows because there is no easy way to mark what things have already been processed by a previous step of a multi-step process. For example, in Google Ads, we add a label to any campaigns that we pause with our Flexible Budget script. The label helps the script know what campaigns to re-enable at the start of the next month. With no label support, we have to find other ways to store information about what was done. A potential workaround is to store data in JSON format and write it to a file. At the start of each script execution, it should read in the JSON from the file and use it to decide what should be done by the current script run.

Working without email and spreadsheets

Almost every script I’ve written emails someone when it finds something of interest, whether a broken URL, or a link to the analysis. Because Bing Ads Scripts don’t yet support sending email, we need to rely on UrlFetchApp and some third-party APIs to be able to send an email. You could use a SendGrid account (they have free accounts for low usage) in combination with UrlFetchApp to send emails.

Many reporting scripts rely on Google Sheets to store the analysis in a format the user can easily view or use for further analysis. Unfortunately, there is no support for spreadsheets (or Excel) in Bing Ads Scripts at the moment. Again, UrlFetchApp comes to the rescue as it can be used to read and write files. See an example of how OneDrive can be used to read and write CSV files.

Code snippets to handle current limitations

Sending Emails from Bing Ads Scripts

This code can be used to send an email using your SendGrid account. Just be sure to update the code with your own API key.

Embed code:

Using JSON Between Script Executions

Use this code to store data about what a script did and then use it the next time the script runs to pick up where you last left off. This can help with limits on how many entities you can process in a single script run. To make this work, we’re using a free service that lets you create, edit, and read public JSON snippets.

The easiest way to use this is to manually create a JSON file and then enter the resulting filename in the script so that it can overwrite the file with the latest data every time it runs. To do this, first go to myjson.com and enter some random JSON like {“key”:”Value”} and hit ‘Save’. Then grab the resulting URL and put it on line 3 of the sample code.


Sample code for writing JSON

Embed code:

Sample code for reading JSON

Now that we’ve written the JSON to a data store, we’ll want to pick it up at the start of the next run of the script. That requires slightly different code and you can grab it here. Just be sure to use the same URI that you used to save the JSON in the previous script. And since this is a public store, consider checking the integrity of the data before you use it, just in case someone else accidentally overwrote your file.

Embed code:

Storing Results in Google Sheets

The holy grail of saving data from scripts is with spreadsheets and since Google launched ads scripts first, most of us are used to using Google Sheets for this. It turns out that you can send Bing Ads data to a Google sheet but it takes a bit of work as explained here.


I couldn’t be more excited about getting a new tool in my PPC toolkit to help streamline optimizations. As I explore Bing Ads Scripts in more depth, I’ll continue to share learnings here. I hope you’ll reach out to me to share your own experiences so that we can create solutions together and help the PPC community be more effective.

For more, check out 3 differences between Bing Ads Scripts and Google Scripts you need to know.

Contributing authors are invited to create content for Search Engine Land and are chosen for their expertise and contribution to the search community. Our contributors work under the oversight of the editorial staff and contributions are checked for quality and relevance to our readers. The opinions they express are their own.

About the author

Frederick Vallaeys
Frederick (“Fred”) Vallaeys was one of the first 500 employees at Google where he spent 10 years building Google Ads and teaching advertisers how to get the most out of it as the first Google AdWords Evangelist. Today he is the Cofounder and CEO of Optmyzr, a PPC management SaaS company focused on making search, shopping, and display ads easier to manage with rules, scripts, reports, audits, and more. He is a frequent guest speaker at events where he inspires organizations to be more innovative and use AI and Automation Layering to become better marketers. His latest book, Unlevel the Playing Field, follows his best-seller, Digital Marketing in an AI World.

Get the must-read newsletter for search marketers.