Automatically add negative keywords based on “positive keywords” you define.

Perfect for:

  • Shopping campaigns
  • Dynamic search ads (DSA)
  • Text Ads (combat Google’s “close-match”)

Shopping ads and DSA use data you provide to determine which search queries your products will appear for. Not unlike broad-match keywords, AdWords doesn’t always get it right.

Irrelevant terms are rife on Shopping Ads & DSA, and the problem multiplies as bids increase.

The following free AdWords Script helps by adding negative keywords automatically, based on positive keywords you define.

How it Works

You define a list of positive keywords in a Google Spreadsheet, the script then adds negative keywords where the query doesn’t match any of the words provided.

Let’s imagine you sell rucsacks and holdalls. Based on historical performance, you know queries containing “rucsack”, “holdall” or “bag” are all profitable, other queries just waste money.

You would just need to add “ruc”, “hold” and “bag” to the Google Spreadsheet and where queries don’t contain “ruc”, “hold” or “bag” they will be automatically added as a negative.

This can be setup for dozens of words, through dozens of adGroups in dozens of campaigns. Just create a new tab for each campaign, the tab (or sheet) can be named anything.

The negative keywords are added at AdGroup level.

Tip: Create an “all” AdGroup for prospecting

Script timing out? No problem, next time the script runs it will start with any sheets/campaigns it didn’t get round to last time (that’s what the timestamp on cell G1 is for).

Setup

  1. Make a copy of this google spreadsheet
  2. Grab a copy of the script
  3. Enter your campaign name, name the tab whatever you like, and enter your positive keywords
  4. Repeat as necessary (one tab per campaign)
  5. Paste the sheet link into the script
  6. Preview first, then set it to run hourly once you’re happy

FAQ

Does the Script Work with Search/Text Campaigns?

It does indeed.

Just add a Search Campaign to the settings sheet and negatives will be added there.

With that, the script could be used to tame Google’s close variant matching (where “close” is often debatable). For example, if you’re targeting “scrabble” you might want to add queries which don’t contain “scrabble” as negative keywords.

Does the Script Work with Showcase Ads?

Yes! Just set the script up as you would a normal Shopping Campaign.

Version 1.7

Version 1.7 is live!

  • We’ve added more settings, including a Max Conversions query filter
  • The settings are now all on the spreadsheet making it easier to manage
  • The previous version had a bug. It worked fine but still said “Ad Group not found” in the logs. We’ve fixed that.

Custom Scripts – Hire Us

We’ve had dozens of agencies hire us on the back of this script alone, agencies that saw the potential to further automate their way with bespoke solutions.

If you’d like to do the same, you can contact us here.


72 Comments

Sebastian · July 18, 2017 at 9:58 am

Hi,

at first thanks for sharing the script.

But actually it doesn’t work for me. Do i have to change anything? There aren’t any error messages, but the script doesn’t add any negative keywords. It also shows me the positive keywords in the script protocol.

Thanks for helping me out.

Sebastian

    Automating AdWords · July 18, 2017 at 7:50 pm

    Hi Sebastian,

    Do you mind sharing a copy of your sheet with me and I’ll have a look?

    If you prefer not to make it public, please share it with automatingadwords@gmail.com.

    If you prefer not to share it at all, I’ll double check it’s working myself but it may take a little longer.

    Thanks,

    Charles

    automatingadwords · August 9, 2017 at 7:35 pm

    Sebastian,
    Hopefully we sorted this via email, but let me know if not.
    I’ll be posting a new version of this script soon, I’ll let you know once it’s live.
    Thanks,
    Charles

Mark van Hattum · October 28, 2017 at 1:27 pm

Hello,
Does this script works? After running there are zero errors but also zero words excluded.
Mark

Mark van Hattum · November 15, 2017 at 3:59 pm

Hi Charles,
Thanks! Works like a charm!

Cheers.

Mark

Alex · March 13, 2018 at 6:36 am

Hi Charles,

brilliant script! Thanks a lot for sharing.

Cheers
Alex

    Automating AdWords · March 14, 2018 at 6:41 pm

    Alex,
    It’s great to hear that these are helpful, so thanks for commenting.
    Thanks,
    Charles

Jon · March 14, 2018 at 6:11 pm

Charles,

Thanks for making this! I am getting an error when I try to run the script, every negative keyword that it tries to add returns a message “Cannot edit removed entities”.

    Automating AdWords · March 14, 2018 at 6:46 pm

    Jon,
    I’ve tested this and it looks okay.
    The only way I can re-create the error is by actually removing entities. Are you sure there isn’t something (ad group or campaign) which has been removed that you’re trying to target?
    Bear in mind it’s possible to have the same Campaign/AdGroup with the same name, one enabled/pause and one removed. If so it’s likely the issue, you’ll need to re-name the removed entities to something unique.
    Let me know how you get on.
    Charles

Brett Farrow · April 9, 2018 at 10:37 pm

Great script, thanks for publishing this!’

For other users, I noticed is that the script is case sensitive. So if you have a term that is listed as “ABC” or a SKU like “ABC123”, AdWords will display them as “abc” or “abc123”, and the script will turn them into negative keywords.

    Sean Kenney · March 20, 2019 at 1:00 am

    Is this still the case? You’re saying to enter keywords in sheet cells in lower case and there will not be a problem?

      Automating AdWords · March 20, 2019 at 1:12 pm

      The script doesn’t explicitly try to match case. It takes the query from Google and your positive keywords exactly as you enter them and makes comparisons.

      I could be wrong but I believe Google is then case sensitive in that an “ABC” negative won’t filter out “abc” searches.

      I personally enter lower and uppercase positive keywords (example in the settings sheet template) to make sure.

      If you figure out the answer to this please share.

      Thanks

Scott · April 19, 2018 at 8:46 pm

Hello,

thanks for the awesome script!

Quick question, I copied the script and adjusted the Google Sheet URL (line 10). However, I am receiving the error: “Invalid argument: url (line 11)” Any idea how to fix this?

    Automating AdWords · April 23, 2018 at 5:23 am

    Hi Scott,
    It seems to be working for me.
    Please see this screenshot, maybe check your matches mine?
    A few things to check:

    • The spreadsheet URL is between the quotes, again see the above screenshot example.
    • The account you’re using has access to the sheet (although it’s unlikely that’s the issue looking at the error)

    If you’re still having trouble, feel free to email the code you’re using to charles@automatingadwords.com and I’ll have a gander myself.
    Thanks,
    Charles

Ted · May 1, 2018 at 9:35 pm

Hi Charles,

First, I wanted to say thank you for putting this script together!

I noticed the script is adding negative keywords to more ad groups than just the one that had the unwanted search term. Is there a way to get it to only add negatives to the relevant ad group?

Sincerely,

Ted

Brian · May 29, 2018 at 8:34 pm

Thanks for sharing. Just wondering, is it possible to adapt this for broad match modifier terms vs just exact match?

    Automating AdWords · August 13, 2018 at 7:55 am

    Brian,
    There is now.
    Please find the updated version here.
    Note the option on line 15.
    Thanks,
    Charles

      Sn · May 9, 2019 at 1:41 pm

      the link is not working. Firstly, thank you for your amazing work.
      I believe the issue for Broad match modifier is critical.

        Automating AdWords · May 20, 2019 at 6:36 pm

        Hi,
        Please use the links under the Setup section, above.
        I’ve just checked and they look good to me.
        Thanks

Mary Harrison · July 13, 2018 at 6:35 pm

Hello!

I love this script and it seems to be working for our Shopping campaigns; however, whenever I set it up for a DSA campaign I continue to see that the ad group is not found:

Adding the negative keywords…
AdGroup All Pages not found in the account. Check the AdGroup name is correct in the sheet.

The ad group name is in the account – could duplicate ad group names across multiple campaigns be an issue? Thanks!

    Mary · July 13, 2018 at 6:37 pm

    I tried making the ad group name unique and it didn’t work :(

    Automating AdWords · July 13, 2018 at 7:42 pm

    Hi Mary,

    Excellent to hear the script is proving useful.

    I’ve updated the script, it should work now. Please let me know if not.

    Latest

JD · July 24, 2018 at 9:45 am

Hi Charles, many thanks for sharing this plugin. I’ve got the same problem Mary is experiencing: For our shopping campaigns, it’s working perfectly. For DSA campaigns, the protocol says

Adding the negative keywords…
AdGroup *ad group name* not found in the account. Check the AdGroup name is correct in the sheet.

and repeats this step over and over again. The adgroup name is definitely correct, I’ve already created unique names for the ad groups, so that’s not the problem. I’m using the latest version of the script and even created it from scratch to rule out any errors on that side. Do you have any advice on what the error might be?
Thank you very much

    JD · July 25, 2018 at 7:30 am

    Actually, the script always outputs this error now. Could version 1.5 be bugged? It’s not adding the negative keywords to any ad groups.

      Automating AdWords · August 13, 2018 at 7:40 am

      Hi JD,
      We’re struggling to replicate the error at our end.
      We’d be happy to login and take a look, however.
      I’ll send you an email.
      Thanks

Mary · August 8, 2018 at 12:11 am

Hello, again! I am wondering if there is any way to denote match types of the positive keywords in the Google sheet that the script will recognize?

Thanks!

    Automating AdWords · August 13, 2018 at 7:39 am

    Hi Mary,
    There isn’t at the moment, no, but I’m sure we can help.
    Which match types are you looking to add?
    Do you think multiple scripts would suffice, one for each match type? That would be the quickest method at our end.
    Thanks

    Automating AdWords · August 13, 2018 at 7:56 am

    Mary,
    I’ve updated the script.
    Please find the updated version here.
    Note the option on line 15.
    As per my previous comment, if you need to run multiple match types one option is of course to setup the script multiple times.
    Hope that helps.

      Andrew · April 17, 2019 at 1:11 pm

      http://prntscr.com/nd7ggg
      Link is 404.
      Could you send me this script?

        Automating AdWords · April 17, 2019 at 1:47 pm

        Hi,
        Please see the script link above in the Setup section.
        It’s the latest version.
        Thanks

Richard · August 17, 2018 at 2:03 am

I’ve ran the script and it seems it can’t find the ad group when applying the negative kw’s.

It searches the ad group and finds negative kws, then it says adding negative kws, then the message says “ad group not found in the account. Check the ad group name is correct in the sheet” it is correct so what am I doing wrong?

Melissa · October 17, 2018 at 5:25 pm

Hi – I love this script but is there a way to ensure negatives are added after just 1 impression (versus click)? I put 0 in the click minimum box hoping to achieve this result but it doesn’t seem to work. Thanks in advance!

    Automating AdWords · November 22, 2018 at 12:27 am

    Hi,
    Ah yes, that’s because it will look for queries with >0 clicks i.e. 1 or above.
    Please comment out (add two slashes before) line 87 and it will work.
    Before: + ” AND Clicks > ” + queryClickMinimum
    After: //+ ” AND Clicks > ” + queryClickMinimum
    Hope that helps, please let me know if not.
    Thanks!

    Edit: You can actually just update the “queryClickMinimum” option at the top of the script. Set it to -1 to disable it. I’ve updated the instructions above explaining this. Thanks.

      sean kenney · March 20, 2019 at 1:22 am

      Is this still true? Or has there been an update?

        Automating AdWords · March 20, 2019 at 1:08 pm

        Sean,
        My edit is still correct although now it’s even easier.
        In the sheet there’s a Min Query Clicks option. Just set it to -1. That will mean clicks need to be more than -1 i.e. including zero.
        Hope that helps

Martina · November 6, 2018 at 10:58 am

This is a great script, thanks a lot!
When implementing it, I faced one issue:
In an example: I only want the ads to show for everything that contains ‘sunflower’ so I put ‘sunflower’ in the table/Google sheet. I selected phrase match in the script (line 15) but I would like the script to add the negatives that do not contain ‘sunflower’ as an exact match negative instead of a phrase match negative.
Does that somehow work?
Thanks :)

    Automating AdWords · November 22, 2018 at 12:24 am

    Hi Martina,
    The match type on line 15 only determines the match type of the negative keyword which will be added.
    E.g. if you’ve put “sunflower” in the sheet then the query “boxing gloves” will be added as a negative keyword. The match type of “boxing gloves” is determined by what’s on line 15.
    I must say I’m unsure how a match type could be incorporated otherwise, but I’d love to discuss it. Please get in touch if you think we might be able to help.
    Thanks, and apologies the instructions weren’t clear.
    Charles

Stephen · November 6, 2018 at 7:36 pm

I was curious if this Script could be easily edited for using on Showcase Ads? I have tried messing with the Script, but the logs seem to be saying these Ad Groups are not being read the same as a normal Shopping Ad Group. 1 possible issue is that these Ad units use “Engagements” instead of Clicks. I tried setting the Minimum Clicks as 0, but nothing has worked thus far.

Thanks, Stephen

    Automating AdWords · November 22, 2018 at 12:16 am

    Hi Stephen,
    It should work but it’s not something we’ve tested. Or can test right now, actually.
    I’d happily login and take a look for you. I’ll send you an email.
    Thanks,
    Charles

James · November 20, 2018 at 12:00 pm

20/11/2018 11:54:54 Parsing error. Please check your selector. (file Code.gs, line 83)

Hi guys, getting the above error, any ideas?

Can’t seem to figure it out!

Thanks

    Automating AdWords · November 22, 2018 at 12:09 am

    Hi James,
    The selector on line 83 dynamically looks at the campaign name (on the sheet) and a click minimum (from the top of the script).
    It’s almost certainly one of those two causing the error, most likely the campaign name.
    Is there anything in the cell containing the campaign name which could be causing issues? We’ve seen people accidentally put line breaks in cells in the past, for example. Certain punctuation such as quotes would also trip this up.
    I’ll send you an email so we can discuss further in private.
    Thanks

Blanca · November 29, 2018 at 8:22 am

Hi, thanks for sharing :)
Is there any option to ad this negatives to a negative list instead of the adgroup? this way, we can share between campaigns with the same objective (ie. appear only with searches with some brand in their text)

Thanks again

    Automating AdWords · November 29, 2018 at 9:08 pm

    Hola Blanca,
    I’ve added this to our ever-growing list of suggestions, but I can’t promise we’ll get round to it anytime soon.
    If you’d like to hire us to do the work (which we highly recommend) please get in touch.
    Thanks,
    Charles

Scott · December 14, 2018 at 6:55 pm

What a wonderful script! It’s working perfectly but how do I set it to run hourly as you mentioned in the directions?

    Automating AdWords · December 14, 2018 at 7:26 pm

    Hi Scott,
    Glad you like it!
    Yeah, they’ve hidden the schedule away a bit in the new UI.
    Within the scripts section if you hover over the Frequency column a pencil should appear. Click that and Bob’s your uncle.
    Charles

      Scott · December 14, 2018 at 8:38 pm

      Thanks! We also need some custom scripts written for us and I see that is a service that you provide. You guys still do that? If so I will email you what we are looking for.

        Automating AdWords · December 14, 2018 at 9:17 pm

        Scott,
        We do indeed! Yes, please do.
        You can use our form here: http://automatingadwords.com/custom-solutions-hire-us/
        If you want to give us a general idea of what you’re looking for I’ll put a brief together. Once we’ve agreed on the spec I’ll send a quote. If you then want to go ahead we usually complete scripts within a fortnight.
        Have a good weekend in the meantime.
        Thanks,
        Charles

Scott · December 24, 2018 at 2:06 pm

Is it possible to exclude good keywords. Possibly by adding them to the Google sheet?

Marco · January 9, 2019 at 11:55 am

Hi Charles,
Thanks for sharing.
is it possible to automatically add as “negative keywords” search terms that DO NOT contain certain words?
If yes, how can i do that?
Thanks again
Marco

    Automating AdWords · January 10, 2019 at 12:28 am

    Hi Marco,
    That’s exactly what this script does!
    To quote the above:

    Let’s imagine you sell rucsacks and holdalls. Based on historical performance, you know queries containing “rucsack”, “holdall” or “bag” are all profitable, other queries just waste money.

    You would just need to add “ruc”, “hold” and “bag” to the Google Spreadsheet and where queries don’t contain “ruc”, “hold” or “bag” they will be automatically added as a negative.

    I hope that makes sense, I’m here if you have any more questions.

    Thanks,

    Charles

Craig · January 9, 2019 at 8:15 pm

Thank you so much for this awesome script! Works great.

Only thing – Is there a way to modify the script to only add search terms as negative keywords with < 0.01 conversions?

    Automating AdWords · January 10, 2019 at 12:33 am

    Hi,
    Glad you like it!
    Yep. Where it says:

    + ” AND Clicks > ” + queryClickMinimum”

    Add another line below it:

    + ” AND Conversions < 0.001 "

    Or if that doesn’t work you’ll need to do:

    + ” AND Conversions = 0 “

    If neither work, get in touch here and I’ll send you a file with the revised code.

    Thanks,

    Charles

      Craig · January 10, 2019 at 2:11 am

      Thank you so much Charles. Worked perfectly. Greatly appreciated!

Andy · January 14, 2019 at 10:08 am

Hey Charles,

I was previously using this script with no issues whatsoever, it really helped to turn an account around for me, now we have rebuilt the account due to a new website… the script is now throwing a “can’t find ad group” error as some others have mentioned in these comments, I really can’t work out why this is the case as everything seems correct for me… Any ideas? Thanks in advance

    Automating AdWords · January 15, 2019 at 8:06 am

    Hi Andy,
    I’ll share here what I mentioned in the email.
    Here are some possible reasons:

    • If there’s any white space or breaks around the Campaign name or Ad Group name, it might not work. This can happen when names are copied from somewhere
    • Apostrophes in names could also cause issues
    • Maybe you don’t have the latest version, version 1.6?
    • There’s an Ad Group or Campaign with the same name which has been removed

    Thanks,

    Charles

Patrick Geijtenbeek · February 4, 2019 at 4:00 pm

Love the script! However I’m looking to a sollution to only exclude on CAMPAIGN level, tried to rebuild the script, but can’t get it to work. Is there a way you guys can help me out?

    Automating AdWords · February 5, 2019 at 11:18 am

    Hi Patrick,
    We’re available for hire if you want less hassle and more assurance, but I think you can do this yourself:
    1) Swap var adGroupIterator = AdWordsApp.shoppingAdGroups() with var adGroupIterator = AdWordsApp.shoppingCampaigns()
    2) Swap var adGroupIterator = AdWordsApp.adGroups() with var adGroupIterator = AdWordsApp.campaigns()
    3) Remove .withCondition(“Name = ‘”+adGroupName+”‘”)

    That’s a lazy way of doing it but it should work.

    As always I’d recommend previewing and reviewing before running the script.

    The reference is excellent if you get stuck. Or pop back on here, of course.

    Thanks,

    Charles

Jared · April 16, 2019 at 4:22 pm

Hello, I would like to be able to add multiple AND checks for the positive keywords. For example, searches from x ad group must contain the word “online” AND “courses” in order to be deemed acceptable. So if a search term was “engineering courses”, this would be added as an exact match negative keyword because it didn’t contain “online”. Hope that makes sense, would this be possible?

In addition to this, I am also interested in adding these keywords to a specific negative keyword list (e.g. “auto negs”) and a bunch of other stuff, do you charge per hour or per project? Please feel free to answer here but also drop me a message on my email address (in the comment field).

    Automating AdWords · April 21, 2019 at 10:10 am

    Hi Jared,

    I’ve sent you an email, but here’s my response regarding ANDing together terms for everyone else:

    It’s currently possible. The No. of Matches column is how many of the words need to be matched.

    To use your example, if you set the No. of Matches to 2 then add both “online” and “courses” only queries with both “online” AND “courses” will be saved – everything else will be added as a negative keyword.

    Hope that helps,

    Charles

Andrew · April 17, 2019 at 3:05 pm

Could this script do Not add negative keywords but only notify to email about irrelevant search queries which could be as negative words?

Josh Haynes · May 20, 2019 at 10:08 am

Hi,

Thanks for sharing this. I can see how useful this would be although I can’t seem to get it to work.

I am using the updated version that was posted within the comments (https://docs.google.com/spreadsheets/d/1UKeGsk9hopxePETrEtyC2_GIPK4msTr1lvhYcWoeyB4/edit#gid=0) although I am receiving this error message – https://docs.google.com/drawings/d/1DVYrkXeSt2EimMelz8aIYu6G4pYDQukPPik8nCyyPbo/edit?usp=sharing

The message says the error is on line 125 although this doesn’t seem to be correct. I have also tried to update the date range within other areas of the script without any joy.

I would really appreciate it if you could help with this.

Thanks,

Josh

    Automating AdWords · May 20, 2019 at 6:36 pm

    Hi Josh,
    It looks like you’re using the updated script but the old spreadsheet template.
    Please see the latest template (and script) under the Setup section above.
    Let me know if you have any further issues.
    Thanks

Paul · July 2, 2019 at 6:01 am

Hello,

I’ve been using this script for a couple days but it seems to be adding some negative keywords that it shouldn’t be. For ex, lets say I have the phrase match “toyota tacoma”, it will add “2019 toyota tacoma” to the negative kw list.

not sure why, any ideas?

Thank you

    Automating AdWords · July 3, 2019 at 8:09 pm

    Hi Paul,
    It’s difficult to say without seeing your settings sheet, but something to bear in mind: there’s no such thing as “phrase match” when it comes to listing positive keywords (the vertically listed terms we’re using to determine what we want to keep). I.e. only add words without quotes, brackets, etc. Please see the template above for examples.
    If it’s not that please reply to this comment with your sheet link (Share > Get Shareable Link) and we’ll have a look. Note we won’t publish the comment to keep your sheet link private.
    Thanks

Chris · July 10, 2019 at 2:09 pm

Hi

Is it possible for the script to add negatives when where the search query does not exactly match the positive keywords as defined in the spreadsheet? So if my positive keyword is “running shoes” and the search query is “cheap running shoes”, can I get this added as a negative?

Thanks

Chris

    Automating AdWords · August 3, 2019 at 4:10 am

    Hi,

    Yes, so if you add a positive keyword of “running shoes” with a No. Matches of 1 it will exclude any query which doesn’t contain “running shoes”. Note you don’t need to add the quotes to the sheet, of course.

Michelle · July 31, 2019 at 2:25 pm

Hello,

I got the same problem as Paul has. Did you manage to find a solution?

For example with my script, I added ‘white suit’ as a positive keyword in the spreadsheet and it still excluded exactly ‘white suit’ as an exact keyword. I run this script daily.

My settings in the spreadsheet are:
min Query Clicks: 1
Max Query Conversions: 5
Date Range: LAST_30_DAYS
Negative Match Type: Exact
Campaign Level Queries: No
No Of Matches: 2

Could you share your thoughts?

Thanks!

    Automating AdWords · August 3, 2019 at 4:12 am

    Hi,
    If you set the No Of Matches to 1 it should be fine.
    With it being 2, the query needs to contain “white suit” plus one other positive keyword in your list. Otherwise it will be added as a negative keyword. “white suit” only matches 1 condition so gets added as a negative.

    Hope that helps!

      Michelle · August 5, 2019 at 9:26 am

      Right, I thought that metric would look at the word per cell but it looks at the entire list as I understand correctly.

      Thanks for the help, I will try that!

Leave a Reply to Chris Cancel reply

Your email address will not be published. Required fields are marked *