Exclude exact in DSA adgroups

Automatically exclude all exact keywords in DSA adgroups. Search traffic will land in the most relevant adgroup.

Start Now!
Exclude exact-match keywords in DSA adgroups
Exclude Get started!

Do you use DSA adgroups within your search campaigs? You may be using DSA for keywordmining or to increase your impressions. If you have separate DSA adgroups in your account, it is recommended to exclude all search terms that you already advertise on. Then your adgroups do not compete with each other and the searchterms enter the adgroup with the most relevant ads.

This script helps you with this and is easy to use. It automatically adds all exact-match keywords as a negative keyword in your DSA adgroup.

Do you use seperate DSA-campaigns? We also have a script to exclude keywords that way!


  • LOG: Specify whether the script should report the intermediate steps, by adjusting the value to 'true'.
  • DSA_ADGROUP_NAME: Enter (part of) the name of your DSA adgroups.
The script
// Copyright 2022 - until eternity
// Free to use or alter for everyone. A mention would be nice ;-)
// Created by: Tibbe van Asten
// for Adsscripts.com
// Created: 01-10-2019
// Last update: 11-11-2022
// This script will help the account kept clean.
// Exact match keywords will be excluded in the DSA adgroups.

var config = {

  // Set LOG to true to check for errors. Once this script runs
  // smootly, set to false to improve script performance.
  LOG : true,

  // All DSA adgroups will have the following mark in the name
  // Use multiple values by using pipes; "DSA|ABC|Etc"
  // Select the keyword match types you want to exclude
  // Use one or multiple BROAD, EXACT, PHRASE. Split by comma



function main(){
  var adGroupNames = config.DSA_ADGROUP_NAME.split("|");
  for(var i = 0;i < adGroupNames.length;i++){
    adGroupNames[i] = ".*" + adGroupNames[i] + ".*";
  adGroupNames = adGroupNames.join("|").toString();
  var adGroupIterator = AdsApp
    .withCondition("ad_group.name REGEXP_MATCH '"+adGroupNames+"'")
    .withCondition("ad_group.status = ENABLED")
    .withCondition("campaign.status = ENABLED")
    var adGroup = adGroupIterator.next();
    var campaign = adGroup.getCampaign();
    var keywordIterator = campaign
      .withCondition("ad_group_criterion.status = ENABLED")
      .withCondition("ad_group.status = ENABLED")
      .withCondition("ad_group_criterion.keyword.match_type IN (" + config.KEYWORD_TYPES + ")")

      var keyword = keywordIterator.next();
      if(keyword.getMatchType() == "EXACT"){ var negativeKeyword = "[" + keyword.getText() + "]"; }
      if(keyword.getMatchType() == "PHRASE"){ var negativeKeyword = '"' + keyword.getText() + '"'; }
      if(keyword.getMatchType() == "BROAD"){ var negativeKeyword = keyword.getText(); }
        if(config.LOG === true){
          Logger.log("Excluded "+negativeKeyword+" in "+adGroup.getName());
    } // keywordIterator
  } // adGroupIterator

} // function main()
Show whole script!
Loading Comments
The Experts
Tibbe van Asten Team Lead Performance Marketing
Nils Rooijmans Water Cooler Topics
Martijn Kraan Freelance PPC Specialist
Bas Baudoin Teamlead SEA @ Happy Leads
Jermaya Leijen Digital Marketing Strategist
Krzysztof Bycina PPC Specialist from Poland
How about you? JOIN US!
Sharing Knowledge

Adsscripts.com is all about sharing knowledge. In the current market, PPC specialists like to keep their knowledge and experience to themselves. We're convinced that sharing knowledge can ensure that everyone gets better at their work. We want to change this by sharing our knowledge about scripts with everyone.

Do you also want to contribute? We are open to new ideas and feedback on everything you find on Adsscripts.com.

Contact us

Training &
Contact us!
Adsscripts Training & Workshop