Exclude exact in DSA campaign

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

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

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

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 campaign(s).

Note: if you interrupt a 'regular' campaign, the keywords from this campaign will still be excluded in your DSA campaign. If you still want to be found on these keywords, you have to remove the negative keywords manually.

Do you use DSA adgroups within your campaigns? We also have a script to exclude keywords that way!

Settings

  • LOG: Specify whether the script should report the intermediate steps, by adjusting the value to 'true'.
  • EXACT_MATCH_CAMPAIGN_NAME: Enter (part of) the campaign names for which you want to exclude the exact search terms in the DSA campaign.
  • DSA_CAMPAIGN_NAME: Enter (part of) the campaign name of your DSA campaign(s).
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: 14-12-2022
//
// ABOUT THE SCRIPT
// This script will help the accounts kept clean.
// Exact match keywords will be excluded in the DSA campaign.
//
////////////////////////////////////////////////////////////////////

var config = {

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

  // Identify the campaigns with exact match keywords by campaignname.
  EXACT_MATCH_CAMPAIGN_NAME : "NB",

  // Identify the DSA campaign by campaignname.
  DSA_CAMPAIGN_NAME : "DSA"

}

////////////////////////////////////////////////////////////////////

function main(){

  var keywordsToBeExcluded = [];

  // We'll select all exact match keywords
  var keywordIterator = AdsApp
    .keywords()
    .withCondition("campaign.name REGEXP_MATCH '.*"+config.EXACT_MATCH_CAMPAIGN_NAME+".*'")
    .withCondition("campaign.status = ENABLED")
    .withCondition("ad_group_criterion.status = ENABLED")
    .withCondition("ad_group.status = ENABLED")
    .withCondition("ad_group_criterion.keyword.match_type IN (EXACT)")
    .get();

  while(keywordIterator.hasNext()){
    var keyword = keywordIterator.next();
    keywordsToBeExcluded.push(keyword.getText());
  } // keywordIterator

    if(config.LOG === true){
      Logger.log("Found " + keywordsToBeExcluded.length + " keywords to be excluded");
    }

  // Now we select the DSA campaign(s) and exclude every keyword
  var campaignIterator = AdsApp
    .campaigns()
    .withCondition("campaign.name REGEXP_MATCH '.*"+config.DSA_CAMPAIGN_NAME+".*'")
    .withCondition("campaign.status = ENABLED")
    .get();

  while(campaignIterator.hasNext()){
    var campaign = campaignIterator.next();

      if(config.LOG === true){
        Logger.log("DSA Campaign found: " + campaign.getName());
      }

    for(var i = 0;i < keywordsToBeExcluded.length;i++){
      campaign.createNegativeKeyword("["+keywordsToBeExcluded[i].toLowerCase()+"]");

        if(config.LOG === true){
          Logger.log("Excluded ["+keywordsToBeExcluded[i].toLowerCase()+"] in "+campaign.getName());
        }
    } // negative keyword iterator

  } // campaignIterator

  Logger.log("Thanks for using this custom script by Tibbe van Asten. Winning!")

} // 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
Caring

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 &
Workshop
Contact us!
Adsscripts Training & Workshop