Expanded Phrase Match Negatives Script

While negative keywords stop ads from showing for searches containing a specific term, in order to exclude irrelevant searches and filter traffic through appropriate match types, they don’t use close variant or synonym matching. This means even with a great negative keyword list, your ads might still show on searches that contain close variations of your terms.

If you’re using phrase negative keyword matching, which prevents any search term containing the exact uninterrupted phrase from prompting your ads, you’ll need to be prepared for all eventualities.

For example, when users forget to add a space between words, those searches won’t be blocked by your phrase match negatives!

What’s included?

How does the script work?

This script will boost your phrase negative keyword matching by finding the ones you’re failing to catch due to misspellings. It looks at queries that contain a phrase negative but weren’t excluded (e.g. due to a missing character), and then suggests new negative keywords that exclude those search queries. 

To use it, you enter a phrase which is already a phrase match negative. For example, “free” or “second-hand.”

The script will look through your search query report and find queries which contain that phrase and where the keywords are attached to other words. For example, if you have the following keywords:

Lego freesample”

“buysecond-hand Lego toys”

The script will trim down the queries to make newly suggested negatives like  “freesample” or “buysecond-hand.”

It will then report the performance of queries containing the suggested negatives into a Google sheet, so you can review them and add them as negatives if necessary.

This is shown at both the campaign and account level, so you can decide if you want them as campaign negatives or add them to your shared negative lists.

How do I use it?

In Google Ads, go to Tools, and in Bulk Actions, choose Scripts.

On the Scripts page, click on the big “+” button and paste in the script below. You’ll also need to create a new Google Sheet for the report to go into, and manually edit the following options:

  • phraseMatchNegative is the negative keyword you want to expand on.
  • startDate and endDate determine the date range of the data. Enter them in yyyy-mm-dd format.
  • currencySymbol is used when formatting cost data in the report.
  • campaignNameContains and campaignNameDoesNotContain filter which campaigns the script gets data from. For example, if campaignNameContains is [“Brand”, “Generic”] then only campaigns with names containing “brand” or “generic” are included. If campaignNameDoesNotContain is [“Display”, “Competitor”] then any campaigns with names containing “display” or “competitor” are ignored.
    • This is not case-sensitive.
    • Leave blank, [ ], to include all campaigns.
    • If you need to put a double quote into campaignNameContains or campaignNameDoesNotContain, put a backslash before it.
  • ignorePausedCampaigns should be set to true if you only want to look at currently active campaigns, or false if you want to include them.
  • Similarly, ignorePausedAdGroups should be true to only look at currently active ad groups, and false to include paused ones.
  • spreadsheetUrl is the URL of a Google Spreadsheet, which the results will be copied into. Create a blank spreadsheet and put the URL in here.
  • If clearSpreadsheet is true, any data already in the spreadsheet will be overwritten. If it’s false, then the script’s results will be added at the end of the sheets.

You can also pick impression, click, cost and conversion thresholds. Possible negatives will only be shown if they have metrics over these thresholds. This means you can concentrate just on the most common or expensive typos.

The Expanded Phrase Match Negatives Script code