In this post, we will present a simple script to isolate a single ad for debugging purposes. We will assume you’re working with DFP Small Business and WordPress, since these are among the most common systems, however, the general idea should hold for other systems too.

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. There are hundreds of requests in the Network tab and it’s impossible to figure out what’s going wrong.

The simple solution

If you’re using DFP, in many cases you can isolate an problematic ad by using “Preview Creative“. This will load the ad on a blank page. However, there is a big problem with this method. Many advertisers use 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 foolproof 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.

<?php

// 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) {
	exit('');
}

?>

<html>
<head>
<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:') + 
  '//www.googletagservices.com/tag/js/gpt.js';
  var node = document.getElementsByTagName('script')[0];
  node.parentNode.insertBefore(gads, node);
})();
</script>
<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());
  googletag.pubads().enableSingleRequest();
  googletag.enableServices();
});
</script>
</head>
<body>
<div id="div-gpt-ad-test">
	<script type='text/javascript'>
	googletag.cmd.push(function() { googletag.display('div-gpt-ad-test'); });
	</script>
</div>
</body>
</html>

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). You can read all about WordPress Page Templates right here.

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:

http://www.example.com/ad-test?dfp_id=0000&ad_unit=ROS_300x250_ATF&width=300&height=728

If you want, load up this URL and hit “view source”. What you’d done is a created an empty, dedicated page with exactly one ad slot.

Finally, 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. The great part is 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.

A Third Option

If you’re a developer and don’t mind getting your hands dirty, check out Create An Ad Unit Test Page, Part 2 for another way to do this. This is the technique I usually prefer. It’s the most powerful method, but requires setting up a web server on your local computer, which is way more hassle than most people can handle.

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