Free Google Ads Script for Building Negative Keyword List to Negate Bad Search Terms

I have just scored 200th subscriber for this website and it’s time to celebrate with a free Google Ads script. I wrote a script for building negative keyword list which is free to use by anybody. Here is what the script does:

  1. It creates a new shared negative keyword list (if the list does not exist yet)
  2. It runs search query report looking for low performing queries (=high cost and no conversions)
  3. It compares existing keywords in the shared list against the bad queries from the latest run of the search query report
  4. If the script identifies missing badly performing queries, it will add them as exact negative keyword into the shared list
  5. It applies the shared list to all active campaigns
  6. If you buy the full version, the script sends you confirmation email at the end (you should be using Google account for signing into Google Ads so the email can go out).

***Not the Google Ads script you were looking for? I can also write custom Google Ads scripts to fit your needs. Contact me.***

Alright, so how to use the thing?

  1. Download the script – you can get either free or full version. What’s the difference? In the full version, the script will send you an email in case new negative KWs are added. Free version will not send you this notification.DOWNLOAD FREE VERSION BUY FULL VERSION
  2. Copy the contents of the file and go to script section of your single Google Ads account (=NOT MCC Level)
  3. Create new script
  4. Paste the code
  5. Adjust the input parameters at the top of the script:
  6. Run preview only in case your negative list already exists. If the list does not exist yet, the preview will fail with “Cannot retrieve the next object: iterator has reached the end. (file Code.gs, line 166)”. The reason is that the script needs to have the negative list before adding the negative keywords into it and the preview mode does not create nor remove any entities. When you run the script for real, the negative keywords list will be created automatically in case it does not exist yet.
  7. Run the script for real
  8. Approve all the permissions
  9. Schedule it – ideally daily.

Enjoy 🙂

If you face any issues or the script is not working as expected, let me know in the comment section below!

DZ

JOIN OUR FACEBOOK GROUP

***Not the Google Ads script you were looking for? I can also write custom Google Ads scripts to fit your needs. Contact me.***

21 thoughts on “Free Google Ads Script for Building Negative Keyword List to Negate Bad Search Terms

  1. Cannot retrieve the next object: iterator has reached the end. (file Code.gs, line 95)

      1. Hmm, I have been running the script like crazy here and I cannot see why you’re getting the message. It runs on my side no matter what scenario I try. Based on the message, it looks like the negative KW list is not being created for some reason (maybe some special characters in the name? Too long name?), so there is nowhere to add the neg kws to – which is done via line 95. By any chance, could I have a look into your account? I am really curious to see what the problem is.

        I slightly edited the part of the script around line 85, it may or may not help – I am not sure as I am not able to reproduce the problem. Any hint would be greatly appreciated.

        DZ

  2. Hi Dan, thank you so much for the script. It worked really great for several days.
    But now I got an error – Parsing error. Please check your selector. (file Code.gs, line 47)

    I tried it also with your new 1.1 version, but it shows me the same error.
    The search terms that should be excluded are neither containing more than 10 words nor are longer than 80 characters – so the it should not be the problem of the google ads limits.

    Do you have any idea, what is the issue?

    Thanks
    Tom

    1. Hi Tomas,
      as discussed privately, you had incorrectly defined start date. It needs to be in YYYYMMDD format. (e.g. 20190101).

      DZ

  3. Is it possible to export this into a google spreadsheet? I’d like to review the negative keyword list before uploading it.

    1. Hi Lola,
      in theory yes but the complexity would grow dramatically because you’d have to manually confirm you want to upload some KWs, you don’t want to upload some… Those KWs which you don’t want to upload should be moved to a black list so they are not ever suggested again.

      Then there would have to be second script actually adding approved neg KWs into negative lists.

      It would not be as seamless as now.

      DZ

  4. Hi Dan
    Many thanks for this valuable script. I am running the script without any errors.

    However, the keywords are just not being added to the list. Any ideas? I have tried creating new negative keyword lists, but the keywords never get added.

    Can you please help?

  5. Never mind, I figured out what my issue was.

    I did not realize that “Preview” will not actually create the Negative KW List. Only the “Run” button will do that.

    Thank you for this amazing script! Works just as described.

  6. Hi There!

    I get this error:

    Cannot retrieve the next object: iterator has reached the end. (file Code.gs, line 166)

    I have not made any changes to the code..

    Kind regards,

    Timo

    1. Hi Timo,
      OK, will check it out later today. Maybe something has changed in the Google Ads Scripts environment over the last few months.

      I will get back.

      DZ

      1. Timo,
        in Preview mode, it will fail indeed, because the list is not created yet so the script cannot add the neg KWs into a missing list.

        If you just “Run” the script for realt, it will work because the neg list will be created before line 166 of the code and thus no fail will happen – just tested it myself.

        DZ

  7. I have a question that others probably want as well.
    Can you add a variable where I can store a string that is taken into consideration in the “WHERE” clause? I would use this to run the query only on certain campagins, and only add the list to campaigns of my choosing this way 🙂

  8. I can but there needs to be a qualifier. You wanna list exact campaign names or just “CONTAINS”?

    DZ

  9. I want tot list them using “CONTAINS”. That would be the best way I think.

    Kind regards,

    Timo

    1. Hi Timo,
      I’ve updated the script with a new variable campaignContains where you can set the new campaign filter as CONTAINS condition. You don’t have to do this, it’s only an option.

      Just re-download the script.

Leave a Reply

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