This simple WordPress script can isolate a single ad for debugging purposes. We will assume you’re working with DFP Small Business, but the script could be modified for other ad servers.

What is the problem?

There is something wrong with one of your ads. Maybe it is loading slowly. Maybe it is showing inappropriate content. Maybe it is breaking outside of its box. Unfortunately, there are 3 other ads on the page, and a video player, and a content recommendation widget, and a dozen other trackers and scripts. It’s impossible to figure out what’s going wrong.

The simple solution

If you’re using DFP, in many cases you can isolate a problematic ad by using “Preview Creative”. This will load the ad on a blank page. The problem with this method is that many advertisers do domain detection. The preview appears to come from a different domain than your main site and the advertiser shows a blank or an AdSense ad instead of their normal creative. You can also preview the creative on an existing page of the site, but then you’re back to square one because other ads will be loaded too.

What you need is a very simple page, served from the correct domain, with all the necessary ad code. The process is a little complicated, but the results are worth it.

The better solution

First, download this chunk of code. Save it in your WordPress theme, using a filename such as page-ad-test.php. The filename is very important.


// dfp_id, ad_unit, width and height are required
$dfpId        = $_GET['dfp_id'] ? $_GET['dfp_id'] : null;
$adUnit       = $_GET['ad_unit'] ? $_GET['ad_unit'] : null;
$width        = $_GET['width'] ? $_GET['width'] : null;
$height       = $_GET['height'] ? $_GET['height'] : null;

// make sure only upper, lower, numbers and underscores are allowed
$width        = (int)$width;
$height       = (int)$height;
$dfpId        = (int)$dfpId;
$adUnit       = preg_replace('[^a-zA-Z0-9_]', '', $adUnit);

// exit silently if missing required params
if( ! $adUnit || ! $dfpId || ! $width || ! $height) {


<title>Ad Testing Page</title>
<meta name="robots" content="noindex, nofollow">

<script type='text/javascript'>
var googletag = googletag || {};
googletag.cmd = googletag.cmd || [];
(function() {
  var gads = document.createElement('script');
  gads.async = true;
  gads.type = 'text/javascript';
  var useSSL = 'https:' == document.location.protocol;
  gads.src = (useSSL ? 'https:' : 'http:') + 
  var node = document.getElementsByTagName('script')[0];
  node.parentNode.insertBefore(gads, node);
<script type='text/javascript'>
googletag.cmd.push(function() {
  googletag.defineSlot('/<?php echo $dfpId ?>/<?php echo $adUnit ?>', [<?php echo $width ?>, <?php echo $height ?>], 'div-gpt-ad-test').addService(googletag.pubads());
<div id="div-gpt-ad-test">
	<script type='text/javascript'>
	googletag.cmd.push(function() { googletag.display('div-gpt-ad-test'); });

Then, in the WordPress Admin menu, create a new page. Give this new page the title “Ad Test”. Note that the title must match the name of the file you just created (except lowercase and with dashes instead of spaces).

Now, figure out your DFP Network ID. This number appears in the URL when you visit DFP. Let’s pretend your Network ID is 0000.

Next, figure out the Ad Unit Code for the slot you’re trying to debug. This is the name that appears under the Inventory tab in DFP. Let’s pretend this unit is named ROS_300x250_ATF.

Finally, figure out the width and height for the slot you’re trying to debug. In this case, 300×250.

Combine these parameters into a URL, such as the following:

Load up this URL and hit “view source”. What you have done is a created an empty, dedicated page with exactly one ad slot.

Use the “Preview Creative” tool and provide this page as the URL. You will get the creative you want, serving off the right domain, without any clutter from other ad units or scripts. Note that this page is universal. If you want to debug a different ad unit, such as ROS_728x90, you can by simply tweaking the URL.

The setup is advanced for non-developers, but very do-able!

It’s absolutely useful to day-to-day debugging of creatives. In addition, I’ve made two big discoveries for clients that I was particularly proud of:

1. I was able to quickly isolate some ads that were loading over 50Mb (yes, megabytes) of video. These are bad UX and simply abusive to users.

2. I was able to track down a rogue 3rd party creative that used an 8 second auto-refresh to earn tons of money for the advertiser while paying a tiny CPM to the publisher.

Drop Us a Line

We’re dedicated to working with the hungriest minds in our field. If you’re involved with digital content production or digital advertising and marketing, we’d love to hear from you. Big, small, experienced or beginner, please feel free to get in contact if you think we can be of service.

Say Hello