Skip to main content

Download the Marketing with Purpose playbook to get actionable tactics to start your inclusive advertising journey today

Microsoft Advertising Scripts are pieces of JavaScript code you can use to automatically create, change, or delete items in your account based on custom criteria. You can make hundreds (or thousands) of changes across your account all at once, without needing to make the changes manually.

After reading this Study guide on Microsoft Advertising Scripts, you will understand how to:

  • Schedule campaigns linked to a launch or sale.
  • Have an ad pause automatically when the item its advertising is out of stock.
  • Make a rule across your account to increase broad-match keyword bids.
  • Utilize the Google script import option.

Using Microsoft Advertising Scripts

Scripts are most helpful for people who manage large campaigns and/or a large number of campaigns. It also helps to have some experience scripting in JavaScript.
It's important to keep in mind that Microsoft Advertising Scripts can make wide-ranging changes to your campaigns, and that scripts do not have an "Undo" button. If you find this prospect daunting, then automated rules might be more suitable for you.

Create and run Microsoft Advertising Scripts

To get started, click Bulk Operations on the left navigation pane, and then click Scripts. This is the main Scripts page where you will see any scripts you have already created.

Create ad extension

Click Create script. In the script editor, write or paste in your script.

  • To see example scripts that you can copy, click Show examples.
  • For instructions on scripting, take a look at our Scripts documentation, and for more script snippets you can copy, check out our scripts code examples.

Create ad extension

Click Save.

Click Preview to see a list of all the changes this script will make. Previewing a script is optional but is strongly recommended. If you want to run the script right away, click Run script now. If you want to run the script at a certain time, or at multiple specific times, click Create schedule.

Note: If you have multiple accounts and want to run a script across them, you'll need to create the script from your Accounts Summary page — click Bulk Operations and then Scripts. If you share accounts with other account managers, be aware that only the author of a script will be able to see and run that script.

Preview & review your scripts

It’s recommended that you validate the accuracy of your scripts before they run. Remember, preview does not modify your account.

Create ad extension

Validate the accuracy of your scripts before they run to align with your marketing goals. Ensure there aren’t conflicting scripts running (i.e., other accounts for multi-accounts, etc.).

Create ad extension

Managing Scripts

After you run a script, it will appear under Logs on the main Scripts page. There you will see when the script ran, how long it took to run, how many changes were made, and how many changes failed. For more information on what the script did:
  • In the script's Summary column, click View details.
  • On the script's Log details page, you'll see all the changes the script made.
  • To see how the script made these changes — as well as any errors encountered and log messages you included with the script — click Logs.
To run a script that you have already created:
  • Find the script in your list of previously created scripts on the main Scripts page.
  • Click Run — or click Create schedule to have the script run at a certain time, or at multiple specific times.

Scripts & Google Ads

You can use scripts you created in Google Ads by simply pasting them in. When you click Save, we will automatically make some changes to make them compatible with Microsoft Advertising.

However, you will need to update the script manually to fix the following compatibility issues:

  • If the script calls the budget selector, it returns only shared budgets. To get a campaign's individual budget, you must access it directly from the campaign.
  • If the script includes IDs, you’ll need to turn them into strings by wrapping them in double quotation marks. For example, you’ll need to change .withIds([1234]) to .withIds("1234"]).
  • If the script calls an entity's getStatsFor() method, you’ll need to change the call to getStats() and specify the date range using the selector's forDateRange() method.
  • If the script calls the keyword selector's withIds() method, make sure you pass only an array of keyword IDs. In Microsoft Advertising, keyword IDs are unique, so there’s no need to pass an array of ad group ID and keyword ID pairs.
Note: If the script adds negative keywords with broad match type, Microsoft Advertising converts them to phrase match type when adding them to the account. Microsoft Advertising doesn't support broad match type for negative keywords.


You can easily access Microsoft Advertising Scripts online which allow significant efficiencies. Scripts will cover a handful of scenarios in Campaign management.

Remember these key points when considering your Scripts options:

  • Reuse your Google Ads scripts by copying and pasting.
  • You can find a predefined script within the reference documents to fit your need.
  • Enable complex operations through writing your own customized JavaScript code.

Thanks for reading this Study guide on Microsoft Advertising Scripts. Continue studying or take the Microsoft Advertising Certified Professional exam to become certified.

Please note all features in this Study guide may not be available in your market.