How can I automate my campaigns with Microsoft Advertising Scripts?
Learn how to automate your account and campaigns with Microsoft Advertising Scripts.
Here are some examples of using scripts:
- Schedule campaigns linked to a launch or sale.
- Have an ad pause automatically when the item it's advertising is out of stock.
- Make a rule across your account to increase broad-match keyword bids by 25% for keywords that generated more than 100 impressions that day.
Using Microsoft Advertising Scripts
Who should use scripts?
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.
How do I create and run Microsoft Advertising Scripts?
On the left navigation pane, click Bulk Operations and then Scripts (or from the global menu at the top of the page, click Bulk actions and then click Scripts). This is the main Scripts page where you will see any scripts you have already created.
- 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.
- 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.
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.
How do I manage scripts?
After you run a script, it will appear under Logs on the main Scripts page (From the global menu at the top of the page, click Bulk actions > Scripts. 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.
Can I use the scripts that I created in Google Ads?
Yes, just paste them right 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() 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.
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.
For more information
Visit our documentation site for details on scripting: