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).


  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


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.

What if the script isn’t working?

Please check you have the latest version of both the script and the sheet. Then check the logs to see if there’s a message explaining the issue e.g. a missing negative keyword list.

Here are some common issues and fixes:

  • Delete any tabs you’re not using including the one from the example.
  • Ensure your “No. Of Matches” is correct. If there is only one positive keyword and this is set to “2” then it will look for the positive keyword twice.
  • Set the min clicks to -1 to include 0 or more clicks (remove the filter).
  • Check the script isn’t timing out. If so, you may need to limit the number of negative keywords being added.

If all looks well and there’s still an issue please leave a comment below.

Version 1.9

Version 1.9 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 script will convert the ‘positive keywords’ to lowercase, making the script case-insensitive

Pro Version

Get in touch if you’re interested in the Pro version which includes:

  • Negative Keyword List support
  • Multiple campaign per tab support
  • Checks to only add new negative keywords
  • Automatic negative keyword list creation once full (5000 keywords max)
  • Impressions filter
  • Campaign name filter
  • Option to skip campaigns/adgroups
  • Log the first 500 negative keywords added to the sheet
  • Improved performance, logging and error catching to reduce costly mistakes

Custom Scripts – Hire Us

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

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


Sebastian · July 18, 2017 at 9:58 am


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.


    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

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



      Michal · September 13, 2019 at 12:27 pm

      Hello, i have you latest version of script, but when I RUN script, I can see negative keywords in protocol or in preview, unfortunately, they are not adding to ad groups. Can you help me with it?

    automatingadwords · August 9, 2017 at 7:35 pm

    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.

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

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

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

Hi Charles,
Thanks! Works like a charm!



Alex · March 13, 2018 at 6:36 am

Hi Charles,

brilliant script! Thanks a lot for sharing.


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

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

Jon · March 14, 2018 at 6:11 pm


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

    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.

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.


Scott · April 19, 2018 at 8:46 pm


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 and I’ll have a gander myself.

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?



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

    There is now.
    Please find the updated version here.
    Note the option on line 15.

      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

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

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


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.


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.

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?


    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.

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

    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.

      Louise · February 5, 2019 at 3:39 pm

      Hello. Many thanks for producing this script. Like Mary, I would like to specify the match types for ‘positive’ keywords. Can I do this directly in the spreadsheet by using “, [ and + or is there a better way? You reference an updated script in your response to Mary but the link is unfortunately dead. Looking forward to hearing from you.

      Andrew · April 17, 2019 at 1:11 pm
      Link is 404.
      Could you send me this script?

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

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

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

    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.

    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

        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.

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.

James · November 20, 2018 at 12:00 pm

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

Hi guys, getting the above error, any ideas?

Can’t seem to figure it out!


    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.

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.

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.

      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

        We do indeed! Yes, please do.
        You can use our form here:
        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.

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

    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.



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

    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.



      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



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.



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,


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


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 ( although I am receiving this error message –

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.



    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.

Louise · June 2, 2019 at 8:54 pm

Hello Charles. Again, thank you so much for this very useful script. I have two queries. First, How do I format the sheet if there are multiple AdGroups within the campaign? Which cell should the the second AdGroup name go and do I have to repeat the number of matches and keywords cells for each AdGroups? If so, which cells? Secondly, can I please confirm whether I need to add both singular and plural versions of positive terms to each column?

Paul · July 2, 2019 at 6:01 am


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.

Paul · July 2, 2019 at 6:02 am

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

Chris · July 10, 2019 at 2:09 pm


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?



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


    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


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?


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

    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!

Marcus · November 6, 2019 at 3:00 am

Hi, Is there a way where we can add the negative keywords on the campaign level?

    Automating AdWords · November 7, 2019 at 3:51 am

    Hi Marcus,
    I’m afraid not, but if you’d like to hire us to upgrade the script (it won’t take long) please get in touch here.

Nancy · February 19, 2020 at 4:44 pm

Thank you for sharing this! I’m getting the following error: “Parsing error. Please check your selector. (file, line 125)”.

I’ve noticed that it depends on the sheet the script is checking. I’ve tried this script with multiple ad groups, divided over multiple sheets and it usually works. However, for some ad groups I get the error mentioned above. I use the same settings on all sheets. Any idea how I can fix this?

Bram · March 5, 2020 at 12:12 pm


First thank you for this script i’m getting this error when I run the script:

Parsing error. Please check your selector. (file, line 125)

Any advice?


Gabriele Benedetti · March 20, 2020 at 4:31 pm

Hello Guys,
hope you are doing well.

I have a proposal to enhance the script. As time goes by the script risk is to reach the maximum number of negative keywords per campaign, right?

So my idea is to modify the default insertion of the negative keyword NOT directly in the campaign but in a Negative keyword list that will apply to the campaign.
Once this list will reach the maximum number of kw we will need to change to a new one, leaving the old one still working.

Hope my idea is clear =)
A big hug from Bologna Italy!

Joshua Kersh · July 14, 2020 at 10:02 am

Thank you! works perfectly :)

Catie Daus · July 30, 2020 at 3:51 pm

I copied your instructions exactly and nothing happened.

    Automating AdWords · July 31, 2020 at 12:34 pm

    A lot of people use the script without issue, and we haven’t had any issues with it.
    It’s probably your settings. I’d start by making them as broad as possible to ensure it works then scale down.
    As you’ll be aware you can ‘Preview’ to see the would-be results.

Timo · August 7, 2020 at 10:20 am


thanks a lot for this really great script.
I would like to exclude the negative keywords on campaign level (and not per ad group).

Is there a solution for this?

Thanks a lot.

    Automating AdWords · August 30, 2020 at 12:43 pm


    I’ve sent you an email but for everyone else:

    The short answer is no however, the current script allows negative keyword lists.

    It would mean a negative list per campaign which perhaps isn’t ideal, but campaign-level negs could work that way.



Lars · August 25, 2020 at 3:32 pm

Hello, it does not look like the script works? I got this error message in Google Ads: Error: script has multiple “main” functions. (file, line 16; file Negative Keywords Input, line 18; file, line 18)

    Automating AdWords · August 25, 2020 at 3:36 pm

    It looks like you’ve created an extra file ( by accident.
    If you delete that it should work.
    It may be easier to just disable the script and create a brand new one.
    I hope that helps!

Ben · October 14, 2020 at 10:38 am

Hey guys,

quick question: Do I have to enter the ad groups into the sheet or would this also work for all ad groups in one campaign without entering each of them into the sheet? I’m working on large accounts with SKAGs, we often reach the 20k ad group limit so entering all of them is not an option. My list of positive words is exactly the same for all ad groups though. I basically want a negative for every search term that does not contain one of these words for all ad groups in the campaign.


    Automating AdWords · October 14, 2020 at 10:27 pm

    Hi Ben,
    Unfortunately not!
    I’ve sent you an email regarding perhaps creating a new version.

Eva · October 14, 2020 at 6:18 pm

This script is fantastic! Works like a charm to exclude non-branded search queries as exact match negatives from our branded shopping campaigns – exactly what I was looking for! Also thank you for the modification that lets it add the negatives at the campaign level in one of the comments higher up, works perfectly :)

    Automating AdWords · October 14, 2020 at 10:26 pm

    Thanks Eva! We appreciate the positive feedback.

Gideon · November 6, 2020 at 9:39 am


First off all, thanks for the script.

When I preview or run the script nothing happens. I have tested 1 and 2 No Of Matches. still no changes. Any idea what i do wrong?


    Automating AdWords · November 8, 2020 at 2:36 pm

    Hi Gideon,
    Are there any messages or errors in the logs?
    It may be that no search queries fall under your options. Please set the options as open as possible (no minimums, long date range) to see if there’s data.
    Then please also ensure the sheet matches the template with one AdGroup per column.

      Gideon · November 9, 2020 at 1:20 pm

      Hi Charles, Thanks for your feedback.
      I have last 30 days, and no of matches on 1.
      Where should I see the changes. Maybe I look wrong? hope so.


Phil Weaver · November 18, 2020 at 12:38 am

Great script! Will it work for Bing too or just Google? I cant seem to make it work.

    Automating AdWords · December 9, 2020 at 2:24 am

    Hi Phil,
    I know I emailed you, but for the benefit of others this will only work on Google Ads.
    Please let us know if you require a Bing version.

      Mary Lalak · April 15, 2021 at 3:15 pm

      Would LOVE a Bing version!!

      Junior · May 26, 2022 at 5:03 pm

      Is there any chance I can get a Bing version of this script as well?

Sebnem · December 8, 2020 at 2:48 pm

Thanks for sharing the script, it looks super useful.
I had some problems running it, it can only read one tabs (campaigns) in the spreadsheet and does not find any negative keywords.. Is the code still up to date or would would please suggest some changes that might work for me?

I used this spreadsheet

& version 1.7.1

Thanks a lot!

    Automating AdWords · December 9, 2020 at 2:30 am

    It should work!
    I think the problem is the sheet you linked. It isn’t the same as the one listed in the ‘Setup’ above.
    Please give that a whirl and it should be fine.
    Let us know if not.

    Sebnem · December 9, 2020 at 3:23 pm

    Hi Charles,
    Thanks a lot for your quick response, I changed it as you suggest, and it works! : ) But I have another problem, for some reason script only reads the left-most tab(campaign) in the spreadsheet. I previewed it few times changing order of the tabs, and each time it only reads the last tab.
    Have you noted something like this before?
    Have a great day,

Joann · January 8, 2021 at 5:55 pm

Hi, this script is working except it’s also taking my positive keywords and making them negatives??

    Automating AdWords · March 11, 2021 at 11:28 am

    Hi Joann,
    Did you manage to sort this?
    We’ve since tested the script and it works for us. A lot of our clients use the script, too.
    I’d check you have the latest version of the script and the sheet to begin with.
    Then if there’s still an issue please respond and I’ll send you a private email to get to the bottom of this.

Joe · January 26, 2021 at 5:22 pm


Does this script only add negative keywords if it doesn’t match the positive keyword exactly even in terms of word order? For example:
If my positive keyword is “Dog Collar”
When I run the script it seems to add the negative “Collar Dog”

Even though I have the positive as phrase match it still seems to want to add it as a negative keyword just flipped round. In some instances I would want the term to be Collar Dog rather than Dog Collar you see.

Any help is much appreciated.

    Automating AdWords · March 11, 2021 at 11:27 am

    Hi Joe,
    Hopefully you worked this one out!
    The script works by checking if each search query contains your positive keyword.
    So you probably want a positive keyword as ‘dog’ then if the query ‘dog collar’ or ‘collar dog’ contains ‘dog’ then it’s OK.
    Otherwise it’s added as a negative keyword.
    You can also change the matches to 2 then add both ‘collar’ and ‘dog’ as separate positive keywords (on different rows).
    That way the query needs to contain both ‘collar’ and ‘dog. Again both of your examples would pass the test – they would not be added as negative keywords.
    There is no ‘phrase match’ as such when it comes to deciding which negative keywords to add. That’s just when actually adding the negative keywords.
    Hopefully that makes sense!

Thomas · March 9, 2021 at 10:45 am

Thanks a lot for this very helpful script!

One question though:
On Shopping campaigns (haven’t tried others yet), the negative keywords are added to a keyword list but when adding to the adgroup itself, the script throws this error:
TypeError: Cannot call method “addNegativeKeywords” of undefined. (file, line 239)

Can anyone relate and/or advise?

Thanks a lot!

    Automating AdWords · March 11, 2021 at 11:08 am

    Hi Thomas,
    In your logs can you see a log above the error?
    It might say ‘{list name} is not found’
    If so, it’s one of two things:
    – The list doesn’t exist in which case create it
    – The info has been added to the wrong cells. Please check the AdGroup names are in col 5, neg lists in col 6 (leave blank if not using) and keywords starting in col 7.
    Failing that please respond and we’ll sort something out.

Mary Lalak · April 15, 2021 at 3:16 pm

This script is great! Running into one error though. In the logs, it’s showing ” Parsing error. Please check your selector. (file, line 192).” Could you assist?

    Automating AdWords · May 19, 2021 at 7:40 pm

    Hi Mary,
    Sorry for the delay here!
    If you still need help please try the latest version of both the script and the sheet.
    More specifically, it looks like an issue with the Campaign or Ad Group name. There isn’t a quote in either name is there? If so please test removing the quote.
    I’ll send you an email then you can contact me personally if that doesn’t work.

JackB · May 1, 2021 at 9:43 pm

Hello, firstable thanks for your resources, i am really thrilled by the possibility that this solution could automate such a boring part of our job.
Unfortunately i am writing you because the script didn’t work for me. I followed the instructions, added the values in the sheet, tested it and the preview logged this:

“TypeError: Cannot find function getValue in object 2. (file, line 101)”

I double checked that i did everything correctly and eventually tested the script without modifying at all the spreadsheet template and it throws the same error.
I am using Version 1.8, i took it from the Setup section at the beginning of the page, below i re-list the URLs i used today 1 May 2021

link to the script:

Link to the spreadsheet template:

Could you please verify? Thanks a lot!


Morten · May 11, 2021 at 10:00 am

Hello, it seems like a great script but i get an error “TypeError: Cannot find function getValue in object 2. (file, line 101)” i have double check the rows, but i can’t seem to find the issue. Anyone else who have struggled with this issue?

francesco · May 14, 2021 at 11:06 am

I have this error.
TypeError: Cannot find function getValue in object 2. (file, line 101).

Keywords have been added. The campaign name and ad group also match.
If I don’t add the keywords in the sheet then the script works, but of course it doesn’t exclude the keywords.

Nico · May 14, 2021 at 11:22 am


I’ve been trying to make this script work, I would really love to use it! I hope you can help me sort it out.

I’m using the latest version of the script and sheet.

I get the following error when running the script:
5/11/2021 11:30:02 AM TypeError: Cannot find function getValue in object 2. (file, line 10

John · May 19, 2021 at 9:55 am

Hi John,

Thanks for sharing the script it looks super useful, but we are having trouble running it.
The script keeps logging the following error message

TypeError: Cannot find function getValue in object 2. (file, line 101)

We are trying to use version 1.8, is that still the latest version?

Any help greatly appreciated!

Nadine · June 2, 2021 at 9:31 am


first of all, thanks for the script – it’s helping amazingly with big accounts :)

However, the script doesn’t seem to recognize numbers which we have added as “positive keywords”. Search terms containing the specific number will still be excluded from our campaigns. We already tried formatting numbers as text and adding an apostrophe ‘ in front of the number, without any luck.

Do you have any recommendations for what to do about that?

Best regards,

    Automating AdWords · June 2, 2021 at 2:16 pm

    Hi Nadine,
    I have tested the latest version of the script and it seems to be working with regards to recognising numbers. Have you tried using the latest version of the script? The latest version is here 1.8.1.
    Let me know how you get on.

      Nadine Maier · June 18, 2021 at 6:34 am

      Hi Charles,

      sometimes the solution can be so simple… Works like a charm now!


    Tom Roberts · December 4, 2021 at 1:57 pm

    I’m updating to 1.8.1 and I keep getting this error:
    The daterange is not valid. Please check spelling and casing. Valid values: TODAY, YESTERDAY, LAST_7_DAYS, THIS_WEEK_SUN_TODAY, THIS_WEEK_MON_TODAY, LAST_WEEK, LAST_14_DAYS, LAST_30_DAYS, LAST_WEEK, LAST_BUSINESS_WEEK, LAST_WEEK_SUN_SAT, THIS_MONTH, LAST_MONTH (file, line 132)

      Tom · January 3, 2022 at 3:32 am

      Just following up on this? Is this site still being monitored?

Stef van Vliet · September 15, 2021 at 3:03 pm

Great script, thanks a lot! One suggestion: it would be nice to have an “ignore / don’t add as negative” list for specific keywords as well. For example, I’ve set the No of matches to 2, but I want to include a few specific 1 word keywords. These will not get excluded every time the script runs. Anyway, thanks a lot!

Karan Singh · October 2, 2021 at 9:34 am

Hi Team, need assistance with setup. Wanted to get help in setting this script up and discussing other scripts as well. Can you please assist?

    Karan Singh · October 8, 2021 at 5:33 am

    Dear Team, was wondering when I can expect to hear back from you guys.

      Automating AdWords · April 6, 2022 at 6:44 pm

      Hi Karan,
      It was a pleasure chatting via email back in October. Hopefully this has been up and running since!
      Just a note to let me know if I can help with anything else.

Rob · October 6, 2021 at 7:58 pm

Hi Charles,

Thanks for creating this!

My script seems to find 109 search terms on every run, why is it so consistent? It also didn’t seem to pick up the 1000’s of search terms from the last 30 days.

Also, can you run it for impressions before they become clicks?

Thanks again!

    Automating AdWords · April 6, 2022 at 6:43 pm

    Hi Rob,
    One thing with the free version is it doesn’t check what’s already been added. It will just keep adding the same keywords over and over again.
    If it isn’t picking up terms there should be a good reason for it. A click or conversion filter or something to do with the rules?
    As for including anything without a click just set Min Query Clicks to -1 i.e. “include clicks with > -1 clicks” i.e. everything!
    I hope that helps.

Thomas · October 7, 2021 at 2:45 pm

Thanks fo great work! One question: is it possible to exclude keywords based on added negatives to spreadsheet ? For example – I would like to exclude all queries which contains word “cheap juicers” so queries like “cheap juicers ranking” or “best cheap juicers” won’t show up?


    Automating AdWords · April 6, 2022 at 6:40 pm

    Hi Thomas,
    Very sorry for the delay!
    And sorry again, as I don’t think I’m following. That sounds like you just need to add phrase match negative keywords. Do you mind elaborating?

      Thomas · April 30, 2022 at 10:39 am

      Well not exactly. I would like to use script which will exclude all keyword variations which include term „cheap juicers”. So in spreadsheet I use this term and script will add all search queries to negative list which contains “cheap juicers” like: cheap juicers rank, where buy cheap juicers, best cheap juicers, etc. so idea is to tell script which phrase you don’t want instead of which keywords you want like your script does.

        Automating AdWords · May 4, 2022 at 10:55 pm

        Hi Thomas.
        I don’t believe this script can help in that case but I’ll send you an email.

Tom Roberts · December 5, 2021 at 3:12 am

I keep getting this: i’m using the latest version
12/4/2021 10:08:22 PM The daterange is not valid. Please check spelling and casing. Valid values: TODAY, YESTERDAY, LAST_7_DAYS, THIS_WEEK_SUN_TODAY, THIS_WEEK_MON_TODAY, LAST_WEEK, LAST_14_DAYS, LAST_30_DAYS, LAST_WEEK, LAST_BUSINESS_WEEK, LAST_WEEK_SUN_SAT, THIS_MONTH, LAST_MONTH (file, line 132)

    Automating AdWords · April 6, 2022 at 6:38 pm

    Hi Tom,
    Very sorry for the delay!
    Hopefully you realised the issue it the second tab doesn’t match the template above.
    Either fix or delete the 2nd tab and it should be fine.
    Thank you

Ash · February 1, 2022 at 12:23 pm

Hi there!

Absolutely love this script for separating my DSAs, but I’m having a bit of trouble with adding to a Negative Keyword List?
When I add the name of our existing negative keyword list into the Google sheet, I get the below error:

Parsing error. Please check your selector. (file Ella’s, line 236)

I have tried adding the list name both with and without quotation marks, and have tried adding it above just one ad group column and above above all of the ad group names. When I remove the name of the negative list to add the exclusions at ad group level, the script works fine.

Ideally would love to be able to use this with a list for easier management, is this something that can be fixed?

Thank you!!

    Automating AdWords · April 6, 2022 at 6:37 pm

    Hi Ash,
    Sorry for the delay.
    A lot of people use this script – including me – so it really should work!
    Some things to check:
    – Are you on the latest version of the script? Maybe grab it again even if the version numbers match up
    – Is the sheet layout exactly like in the template?
    – Is the name of the list exactly (case sensitive, no extra spaces anywhere) like in the account?

    If that doesn’t work please let me know and share a link to your sheet (where everyone can view it). I won’t publish the comment containing the link address.

Sergiy · February 10, 2022 at 10:12 am

Hi Charles,

First off all, thanks a lot for this very helpful script!

I have one Problem: The script (1.8.1) check only first 2 ad groups and ignoring other added ad groups.

Can you help me please?

Best regards

    Automating AdWords · April 6, 2022 at 6:21 pm

    Please make sure there are no gaps between any of the Ad Groups and each Ad Group has all settings (a name, a number of matches and positive keywords).
    Failing that, it’s possible the script is timing out. If so, it might be getting through 2 Ad Groups then it doesn’t have time to do the rest.
    If that’s the issue you can:
    – Use a short date range
    – Add a min clicks filter
    – Add the Ad Groups to different tabs (same campaign per tab) as each tab will run in order based on which ran last
    If none of that helps please let me know and I’ll email you.

wavey · March 30, 2022 at 7:42 pm

hi, i dont understad how to use it, do i have to put all those codes in where exactly ? any place in the amazon ads app ?

    Automating AdWords · April 6, 2022 at 6:16 pm

    This script is for Google Ads (AdWords). I don’t believe Amazon support scripts.
    They do have an API if you want to setup something similar but we don’t support the Amazon Ads API.

Why You Need a Human Approach to PPC Automation | Loom · September 18, 2019 at 9:12 am

[…] useful script is the Auto-Add Negative Keywords from Automating AdWords. This allows you to define a list of positive keywords that your search queries must contain, and […]

6 5-Minute PPC Fixes Using Automation - Adzooma Blog · June 18, 2020 at 1:40 pm

[…] 4. Automatically add negative keywords with this script […]

Leave a Reply

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