TECH BLOG    « Back to Blog

How I Chose and Installed DoubleClick for Publishers as my Ad Server

I needed something better than just AdSense to serve the ads on Here is my path to choosing and installing DFP.

  – Chris Cagle

While trying to increase the eCPMs (effective cost per thousand impressions) across this site, I realized that what I wanted to accomplish was simply not possible with AdSense. Since Day 1 of's life I was only use AdSense for ad serving and while it had served admirably, there came a point where I needed a change. To be honest, almost all large publisher's probably quickly get to a point where AdSense tags just don't cut it anymore, for two main reasons:

#1 The ability to diversify my advertising dollars.

I could not keep putting all my advertising eggs into the AdSense bucket.

AdSense has historically been known for being tough on publishers and outright banning them from the service without any notice (although, I am sure they have a reason). Google has always been great - well, distant is probably the better descriptor - to me, and I've been a publisher with them since 2005.

I needed to begin to mix in other services like, but I couldn't do that with AdSense.

#2 Create a way to account for direct ad sales.

The best way to get higher CPMs is to simply charge more, but you can't do that on an open market like AdSense or The only way I can do that is by selling my inventory directly to advertisers at a premium price. However, as- expected, AdSense was not up to handing this task.

First Attempt: Custom Ad Rotator Script

Being a developer, I thought I could simply build a script to do this myself. What I ended up building worked for diversifying my ad rotation, but with literally no smarts behind it.

My PHP/JS/JSON custom script allowed to me specify the percentages I wanted to show the units, i.e. 25% and 75% AdSense. And it did just that, although it served indiscriminately.

I knew for a fact that this script was taking away some of the prime ad placements away from AdSense advertisers that would have paid a premium CPM for them. But my script had no idea about that - it was just a random number generator that chose one ad tag over another based on nothing more than luck of the draw.

Another downfall with my custom script is that I couldn't know how many times one ad unit was shown vs another. This is extremely important for direct ad sales where publishers like NoCable are be on the hook to ensure that advertisers get what they pay for, i.e.:

Widgets Inc. needs to serve 200,000 ad impressions within the month of November.

Now, while I could try and back into that with some math... It's all a crapshoot that is destined to fail unless your site generates the exact same number of ad impressions the following month.

Final Attempt: Use Google DoubleClick for Publishers (DFP) for Small Business

Now I was cooking with fire.

The DFP user interface is a little daunting at first, but after a while I kind of got the hang of it. I'm going to skip ahead to how I set things up, and just know that DFP accomplished all my goals and more. Oh yeah, and it's free if your site serves less than 90 million non-AdSense impressions a month.

I think it is safe to say that covers just about all of you reading this article.

Setting up DFP Ad Units

DFP Ad Units are essentially the blank placeholders for where your ads will be shown. A couple good Ad Units would be:

  • Sidebar > Top Ad
  • Sidebar > Bottom Ad
  • Header > Leaderboard
  • Report > Inside 300x250
  • Footer > Leaderboard
  • and so on...

I was haphazard to say the least with the naming and placement of my AdSense units. I wanted to do a little planning when transferring everything over to DFP. I decided to group my units like what I listed above as examples. I made sure that I had the AdSense Inventory setting enabled, and guessed at a few standard size units that should work in those areas of my site.

For instance, I chose the 300x250 and Fluid ad sizes for my sidebar, and the 728x90 and 320x50 ad sizes for my leaderboard units.

Installing the DFP Ad Units

Now installing the DFP ad units on to NoCable was surprisingly the most difficult step.

DFP actually changes each ad tag each time it is generated from their system. It also includes the This is a huge problem for me and the way is structurally setup.

DFP generated this code from their UI:

To place inside <head>:

<script async='async' src=''></script>
  var googletag = googletag || {};
  googletag.cmd = googletag.cmd || [];

  googletag.cmd.push(function() {
    googletag.defineSlot('/218144532/Footer>StandardLeaderboard', [[728, 90], [320, 50]], 'div-gpt-ad-1483234074700-0').addService(googletag.pubads());

And this to place inside the body where the ad should be shown:

<!-- /218144532/Footer>StandardLeaderboard -->
<div id='div-gpt-ad-1483234074700-0'>
    googletag.cmd.push(function() { googletag.display('div-gpt-ad-1483234074700-0'); });

As you can see the HEAD javascript code lists the devi anchor ID of the ad unit inside it. This means that if your site does not keep those two code snippets in-sync, everything goes to hell and nothing works. I luckily found a tutorial on how to combine them and make a HEAD script that never changes.

New & Improved DFP Ad Code:

Here is how that same ad unit above would look in the new "inline" format:

To place inside <head>:

<!-- DFP in Head -->
<script async='async' src=''></script>
  var googletag = googletag || {};
  googletag.cmd = googletag.cmd || [];

And this to place inside the body where the ad should be shown:

<div id="div-gpt-ad-1483234074700-0">
  <script type='text/javascript'>
    googletag.cmd.push(function() {
      googletag.defineSlot('/218144532/Footer>StandardLeaderboard', [[728, 90], [320, 50]], 'div-gpt-ad-1483234074700-0').addService(googletag.pubads());

Note: div-gpt-ad-1483234074700-0 can be string you want, it just has to match across all three instances of it in that ad unit code, and be unique per page. This means that you can only have one div-gpt-ad-1483234074700-0 per page (but that unit can be on multiple pages in total).

Now, the ad unit code is completely independent of the initialization script in the page's head. The ad unit code can now be interchanged without needing to adjust code anywhere else.

I wish DFP gave us the option to export the tags in this format, but they don't: so this is a manual conversion every time I need to export a new or changed ad tag.

Setting up Rotation and In-house Ads

These are done as Orders inside the delivery menu option of DFP.

I currently have three types of orders setup, although they are all essentially the same except one or two settings.

  • Price Priority -

    Since DFP is owned by Google, as is AdSense, they have an extremely tight integration as one might assume. This integration allows for DFP to "test" AdSense in such a way that if they think the CPM of the ad coming from AdSense would be below a certain threshold (the "Price Priority") of a competing ad within your DFP account, then it will serve that alternative ad instead of AdSense.

    What this allows us to do is setup to be served in place of AdSense when AdSense is going to serve a PSA or low-CPM ad.

    The trick here is to set that "price" to something appropriate that benefits both your AdSense and accounts. I found my sort of CPM sweet spot by setting that price rate super low (like $0.50 CPM) and then working my way higher to see how responded.

    Word to the wise: each creative size can have their own price point that works. Mine are all drastically different, ranging from $0.55 to $2.75. Also, don't be alarmed when you earn $0.80 CPM on your ads when you start low like that. What's happening is that you are providing access to only your crap inventory at that price point, so they are responding back with a crap CPM. It will get better as you increase your price priority Value CPM.

    DFP Price Priority

  • House - SlingTV and ExpressVPN

    I currently have SlingTV and ExpressVPN ads setup to attempt to fill 100% of my remaining and unfilled impressions. However, for some reason, DFP doesn't always seem to keep that promise (this month I've had about 70 unfilled impressions).

  • Standard - via direct ad buys

    I don't have any of these types of orders live at the moment, but if I did, I would setup the appropriate quantity of ad impressions that were contracted with me, along with the flight parameters such as start and end dates, and delivery options.

Problems with DFP

DFP is seriously a life saver for the reasons I outlined above, but it does have its downfalls. Here are a couple so that you aren't blind-sided with them like I was.

  1. DFP reporting sucks. I prefer the Yield report inside DFP, but it isn't much to look at. I am sure their reporting is powerful, but everything needs to be custom setup, which is way beyond what I want to do at this point.

  2. AdSense channel and ad unit reporting disappears. You will still be able to get AdSense's gross reporting broken down by device type, site, date, site URL, creative sizes, and others, but the concept of a channel or ad unit has disappeared.

  3. It is soooooo complicated. There are a lot of tutorials around the webs that show you around, but they don't prepare you for the sheer amount of options, settings and different nomenclature you are exposed to when setting up ad units.

Next Steps

This post was all about setting up your site to serve with DFP, but there is so much more I want to dig into. In the future I will try and post on things like:

  • Has my RPM really increased with DFP? I think it has, but I haven't pulled the numbers to know with any certainly yet.

  • What are other price priority partners that I could setup? I heard about Sovrn (formerly Lijit) and Chitika, but I have yet to investigate whether they might be legitimate options.

  • More testing on CPM prices. I think I have hit the CPM sweet spot, but maybe I haven't. I should do another round of testing to ensure that I am not leaving any money on the table by keeping certain ad sizes so low on the price priority chart.


 Like on Facebook