Labels

Use ad exclusions to block ads

Sometimes it's important to prevent certain categories of line items from running on certain parts of your websites. Using ad exclusions, you can group line items, then modify your ad tags to prevent those line items from delivering to particular ad slots.

For example, if you've got a news story about a plane crash, you probably don't want to run airline ads next to it. In these kinds of emergency situations, you can use ad exclusions to stop line items temporarily.

 

How ad exclusions work

Ad exclusions use a combination of labels that you set up in DFP then apply to line items and modifications to your ad tags.

Running ad exclusions is a two-part process:

  1. Begin by setting up ad exclusions in DFP. You'll create ad exclusion labels and apply them to line items to categorize them. It's best to do this part of the process in advance so that you can act quickly when an emergency arises and you need to block certain line items from serving.

  2. When it's time to prevent line items from running, modify your ad tags.

 

Step 1. Create ad exclusions in DFP

To create an ad exclusion:

  1. Create an ad exclusion label.

    Learn more about creating labels.

  2. Apply the ad exclusion label to line items. You can also apply the label to orders or advertisers; the label will be inherited by all of the line items that belong to the order or advertiser.

    Learn more about applying labels.

 

2. Start the ad exclusion by modifying your ad tags

You can implement ad exclusions on both Google Publisher Tags (GPT) and legacy DFP tags.

GPT

If your website uses GPT, you can set both page-level and slot-level exclusions using the GPT API.

Page-level ad exclusions

To set a page-level ad exclusion, add the following line to the <head> portion of your tag before the call to googletag.enableServices():

googletag.pubads().setCategoryExclusion('label_name');

To set multiple category exclusions at the page level, you can either specify each exclusion on a separate line or specify them all on one line:

  • Specify on separate lines
    googletag.pubads().setCategoryExclusion('label_name1');
    googletag.pubads().setCategoryExclusion('label_name2');
  • Specify all on one line
    googletag.pubads().setCategoryExclusion('label_name1').setCategoryExclusion('label_name2');
Slot-level ad exclusions

You can set slot-level ad exclusions in addition to any page-level exclusions you've set. The page-level exclusions won't be overridden. To set slot-level ad exclusion, call the .setCategoryExclusion method when you define the ad slot:

googletag.defineSlot('/network_code/first_level_ad_unit/second_level_ad_unit', [width, height], 'div-gpt-ad-div_ID')
    .setCategoryExclusion('label_name')
    .addService(googletag.pubads());

You can specify multiple category exclusions at the slot level:

googletag.defineSlot('/network_code/first_level_ad_unit/second_level_ad_unit', [width, height], 'div-gpt-ad-div_ID')
   .setCategoryExclusion('label_name1')
   .setCategoryExclusion('label_name2')
   .addService(googletag.pubads());

To clear slot-level ad exclusions, call the .clearCategoryExclusions method (page-level exclusions won't be cleared). This would be useful if you want to refresh the slot, for example.

slot1.clearCategoryExclusions();
googletag.pubads().refresh([slot1]);

Legacy DFP tags

To turn on the ad exclusion, add !c=label_name to the DFP tags where you want to block line items. You can add more than one ad exclusion label to a tag, separated by semicolons.

Tag example
<a href="http://ad.doubleclick.net/jump/sitename/travel_page;sz=widthxheight;key-values;!c=airline;ord=87654321?">

<img src="http://ad.doubleclick.net/ad/sitename/travel_page;sz=widthxheight;key-values;!c=airline;ord=87654321?" width="width" height="height" border="border">

</a>
Some publishers use content management systems to add the ad exclusion key-value dynamically to the webpages where it's needed. To return to the example of a plane crash, you could set up your content management system to insert the ad exclusion key-value into the DFP tags on any webpage that includes a set of keywords related to airlines and accidents.