Tutorial: Building an Ad Platform with DFP
Traditionally, a “church-state wall” has existed between journalists and advertising departments. But in a world of hyperlocal sites run by small teams of independent journalists who need some way to monetize their work, there is no room for that wall. Journalists will need to spend at least some of their time thinking about advertising, which includes mastering an ad serving platform.
There are many ways to integrate ads with your web site, depending on factors such as:
- How much manual work do you want to do?
- How willing are you to give a cut to ad networks?
- Are you technically prepared to maintain an ad platform?
Working with a traditional ad network like AdBrite, Burst, or CasaleMedia is a fairly trouble-free experience — they take care of finding clients for you, as well as all the billing. In exchange, they take a hefty cut of the revenues, as much as 30-40%. With revenue potentials being as slim as they are, that’s a bitter pill to swallow.
A hyperlocal site is going to find its best advertising potential in local businesses, and the big national ad networks simply can’t do as good a job at drumming up that business as you can do on your own. That means you need the ability to upload ads you make yourself (or that your clients provide) into your own system.
And what if you want the freedom to use multiple ad networks, PLUS Google AdSense, PLUS the ability to upload your own ads into the system? Traditionally, that kind of flexibility meant running an ad serving platform like OpenX on your own server, which means doing your own software installation and maintenance. Ad serving can be resource intensive from the server perspective – you may need a beefier hosting plan to make it work.
One excellent alternative is to use Google’s Double Click for Publishers, Small Business Edition (we’ll refer to the product as DFP from now on.) DFP is completely free if you serve fewer than 90 million impressions per month, and Google handles all of the server maintenance (you’d be hard pressed to match the performance of DFP with any self-hosted solution). Most importantly, DFP lets you mix and match network ads, AdSense ads, and your own “creative” however you like, with ads competing in real-time for the highest-paying fit on every page request.
There are a lot of ad serving systems out there to choose from, but in a nutshell, here’s what we like about DFP Small Business:
- Free! (if fewer than 90 million impressions/month)
- High performance/no maintenance
- Nice back-end management system
- Inventory forecasting
- Sophisticated audience targeting
- Lets multiple networks compete, plus AdSense
- Good reporting tools
Note that DFP does not include a billing system. DFP will report how many impressions or clicks each ad has generated, which campaigns have run and what you’re charging for them, and will help you keep track of companies and the contacts within them, but it’s up to you to generate invoices and process payments on your own. This makes a certain amount of sense since some of the ads you’ll be running will come through external ad networks that already have their own billing systems. And Google will of course pay you for the AdSense ads you run. But it would be nice to see an integrated billing system for the parts of the system it makes sense for.
If you’re just getting your feet wet, start with plain vanilla AdSense, then evolve to DFP Small Business. Once your traffic starts hitting that 90 million impressions/month limit, graduate to Double Click for Publishers, which includes more sophisticated tools.
DFP Consultant Rainey Smith was a guest speaker at KDMC’s March 2011 Independent Journalists workshop, and delivered an excellent 1-hour presentation on maximizing ad revenue with DFP. While not strictly part of this DFP tutorial, Smith’s talk is highly recommended, so we’ve embedded it here:
DFP is a “layer” on top of AdSense, so before you can get started with DFP, you’ll need a traditional AdSense account, which is either connected to your bank account or configured to send you checks. It could take a day or two for a new AdSense account to be approved, so get started now.
In case you’re not familiar, Google AdWords is a program through which advertisers can purchase ad placements across the entire internet. Because Google’s search engines index your site’s content, they’re able to place ads that match the topic of any given page. AdSense is the system through which site publishers can register to have these ads displayed on their own sites.
DFP requires you to have an AdSense account for two main reasons:
- When you’re not able to come up with enough custom ads to fill your inventory (your collection of available ad space), AdSense ads will be served in those spots by default.
- For those ads that do fall through to AdSense, Google handles deposits to your bank account.
So: Apply for an AdSense account, wait to be approved, then apply for a DFP account, and again wait to be approved.
You’ll also need the ability to edit templates in your content management system, since you’ll need to place small bits of code provided by DFP into all the right places on your site. If you use WordPress, you can use the built-in Theme Editor for this purpose. Other CMSs will have their own systems for editing templates.
As you’re learning the system, we recommend setting up a “development” or “staging” site where you can test things out. If you don’t have one already, take the time to set up a staging site on a development subdomain at your web host (we recommend something like “dev.mysite.com”, using “dev” in place of “www.”) Alternatively, you can do testing and development with a copy of your site running on your desktop or laptop machine, but setting that up is a topic for another tutorial.
Finally, you’ll need some “creative,” i.e. actual ad graphics to work with as you get started. If you don’t have any handy, feel free to download our sample pack of fake ads.
Before you can be productive in any ad system, you’ll need to be comfortable with the jargon of the ad industry. Here’s a crash course in the terms you’ll see in the DFP interface.
Inventory: The collection of all ad space you have available to sell. You can generally think of your inventory as “The number of ad units on a page times the number of pages you serve.”
Ad Unit: An individual slot where ads can go. Generally defined in terms of placement on the page, e.g. “Main leaderboard” or “Below article,” but can be more granular if you start serving certain ads only on certain pages, e.g. “Top sidebar square on sports pages.” Ad units should be named descriptively, with names that specify the site, the section of the page, and the ad size, e.g. “
IAB Ad Sizes: The Interactive Advertising Bureau is a working group that, among other things, defines ad sizes to be considered as a general convention across the web. This is important because advertisers don’t want to create differently sized ads for every site they advertise on. A list of common IAB ad sizes is here.
Order: AKA “campaign” – a request for a run of ads from a given advertiser, generally focused on pitching a particular product. An order can span across multiple ad units on a site. For example “Joe’s Pizza March Madness Promo” might include four different ad styles, meant to run through the month of March.
Line Item: As described in “Order” above, a campaign consists of one more requests for ads to run. Every order must have at least one line item, which defines the ad to run, the ad unit it will run in, the type of creative to run with it, and optionally any custom targeting.
Creative: The actual ad that will run in a line item. This can be an uploaded image or Flash file, or a pointer to ad code from another ad network.
Targeting: Limiting the scope of the audience to which an ad is displayed. For example, you might want to show an ad only to Spanish-speaking readers, or only to visitors from the local college campus, or only to users with broadband connections. Each line item can be targeted with these options and more.
Placement: Think of a placement as a “category bucket,” using criteria such as “Ads on pages that include user-generated content” or “All skyscraper ads on the site.” Placements are optional, but helpful if you hope to gain ads through Google’s AdWords network, since advertisers will be able to sell their ads into your placements. If you intend to sell all of your ads directly, placements aren’t particularly helpful.
Forecast: Google monitors your site traffic and, over time, builds up a prediction of how many pages you’ll serve in a given time period. Forecasts are also aware of the sections of your site on which particular ads run. Forecasts are used for predicting the availability of inventory, which is in turn important when calculating ad rotations.
Releasing inventory: Frees up inventory that has been reserved by a line item. This lets the forecasting system know it can use these impressions for other reserved line items. In other words, if a line item has been guaranteed to serve, say, 10,000 impressions but you’ve only served 5,000 and now need to end the first campaign, inventory can be released back into the system to make it available to other orders.
Order types: When placing an order’s line items, you’ll be able to give each line item a sale type, which assists in the prioritization process as ads compete for attention.
- Sponsorship: Sell a percentage of all impressions.
- Standard: Sell a fixed quantity of impressions or clicks.
- Network: Allocate a percentage of remaining impressions.
- Bulk: Allocate a fixed quantity of remaining impressions.
- Price priority: Remaining impressions go to highest-paying ads.
- House: Serves when no other ads are booked.
Sale types: Within each order type, each line item has a sale type, which determines how the ad impressions or clicks will be accounted for:
- CPD = Cost Per Day
- CPM = Cost Per Thousand
- CPC = Cost Per Click
Define Your Inventory
It’s time to start putting ads on pages of your staging site. Sign into DFP and click on the Admin tab. You’ll see a panel on the left from which you can set up Contacts (people who will be allowed to log in and view reports and campaign progress), Companies (each ad must be attached to a company in the system for tracking purposes), and Network Settings, which you can use to set a name for your entire network of ads.
Once that’s done, click the Inventory tab at the top, then Ad Units on the left. You can now tell DFP what Ad Unit spaces are available on your site. Let’s start by defining a slot for your main ad – your “Leaderboard.” Click New Ad Unit.
Start by giving the Ad Unit a name. It’s important to use names that include all the information you’ll need to identify it at a glance later on, including:
- The name of the site
- The section or page of your site
- The ad unit’s place on a page
- The ad unit size
For example, these would be excellent Ad Unit names:
(In these examples, ATF means “Above the Fold”). Ad Unit names cannot be longer than 100 characters. See Google’s FAQ on ad unit naming for more information.
Call your leaderboard ad unit something like:
Feel free to add an optional description if you want your advertisers to have more information about the unit. Select the actual ad dimensions from the Size drop-down.
Use the Target Window selector to control whether a clicked ad will be a normal link (_top) or will open in a new browser window or tab (_blank). When linking to other sites on the web, we strongly recommend not using “_blank”. However, links to ads are a bit different from links to content, and setting “_blank” (new window or tab) is the norm for ad links on the web.
Ignore the Placements section for now.
Take a look at the bottom of the page, where it says “AdSense Inventory.” By default, this is enabled, which means that AdSense ads will be served any time you don’t have enough ad orders to match the actual traffic you’re serving. Click the “Show” link to reveal Ad Type and color settings for any AdSense ads that end up being displayed.
Note: If you use AdSense as a fallback, it will only compete with non-guaranteed inventory and other ad networks. It won’t compete with directly placed ads.
Important: Google only allows you to serve up to three AdSense ads on any given page. If you define more than three ad slots per page, you must turn AdSense off for some of them. Do this by clicking the Override link in this section.
Click Save at the bottom of the page. DFP may tell you that it’s now time to create a Placement to run an ad. However, Placements are optional, and we’re going to ignore them for now.
Repeat this process to define two more ad units. In this tutorial we’ll assume you’re working with one leaderboard, one rectangle at 180×150 at the top of your sidebar, and one larger (300×250) rectangle at the bottom of every article, but feel free to modify these sizes to match the needs of your own site.
With your inventory defined, you can now generate the tags that will communicate with DFP and allow ads to appear on your site. In the Inventory section of DFP, click the Generate Tags link at the left.
DFP will display a list of all defined Ad Units. Click the “add” link next to each ad unit you want to generate code for.
Click the Generate Tags button at the bottom of the page and you’ll end up with something like this:
Don’t worry – you don’t have to understand this code – but you do have to place sections of it in appropriate sections of the templates that drive your content management system. If you don’t already speak HTML, this may be the trickiest part of this tutorial. Because every site is constructed differently, we can’t tell you exactly how to go about this, but here are some guidelines. For our purposes, we’ll assume you’re using WordPress – season to taste if you’re running a different CMS.
The top field of DFP’s generated tags is “master code” which enables DFP on your site in general, and defines the names of the ad units you want to display. The bottom field shows as many code blocks as you selected in the previous step.
Start by selecting the code in the top field and copying it to your clipboard. Edit the
header.php file for your site and find the closing
</head> tag. Paste the DFP master code just above that tag.
Now look in the second field of DFP’s tag generator and find the code block named for your leaderboard (pictured below).
Copy that block (and just that block) to your clipboard. Since the leaderboard ad will appear at the top of all pages, the code that triggers that block to appear will also go in
header.php, which is already open. You’ll need to determine its exact placement by brushing up on your HTML, but if you’re using WordPress’ default “2010” theme, we can tell you that it should be pasted just after:
which should be at around line 60:
Save the template file and upload it to the correct theme folder on your web server. Now we need to go through a similar process for the ad that will be displayed underneath every article. Back in DFP’s Tag Generator, copy the appropriate code block from the second field to your clipboard, and paste it to the appropriate place in your templates. In the case of WordPress’ default 2010 theme, the correct place would be in the template
loop-single.php, just after the line:
<?php the_content(); ?>
Finally, we need to get the code block for the sidebar into place. In the case of most WordPress sites, the contents of the sidebar are controlled by the Widgets system, so we won’t need to edit a template for this one. In WordPress’ Dashboard, click on Appearance | Widgets, and drag the “Text” widget into a position in the sidebar. Paste the sidebar ad code into the Widget’s text field and click Save.
All set? Now take a look at your site. If all went well, you should see AdSense ads at the three locations you placed them. Why AdSense ads? Because you haven’t uploaded any real ads or placed any orders yet, so DFP falls back on the default, which is AdSense. We’ll take care of that next.
Placing an Order
With your ad code in place, your site is now displaying default AdSense ads. They don’t pay much, and they’re not very attractive. Your real goal is to attract actual advertisers, receive “creative” from them, and upload it to Google for serving on your site. For this tutorial, we’ll be pretending that KDMC is your advertiser. Download our set of example ads, unzip the archive, and locate the files that begin with “kdmc-“.
Remember that an ad order, or “campaign”, is a request by an advertiser for a run of ads on your site, generally within a given time period. Since an order can span multiple ad units, DFP refers to the various placements within an order as “Line Items.” We’ll be creating one order with three line items, and each line item will have one creative (though it could have more). If we were working with multiple advertisers, we’d have an order for each of them. If a given advertiser were running multiple campaigns, we would place multiple orders. So, the hierarchy looks like this:
Advertiser One Order One Line Item One Creative One Creative Two ... Line Item Two ... Order Two ... ... Advertiser Two ...
For now, let’s create a single advertiser with a single order consisting of three line items, each of which has one creative.
Start by clicking the top Order tab, then New Order:
Give the order a name, such as “KDMC March Workshop Campaign.” Click in the company field and look for KDMC. If it’s not there, select “Add new company” and enter “KDMC” (this lets you re-use company names in the system). In the Trafficker field, enter the email address of someone in your organization who is responsible for uploading ad creatives (may as well enter your own email address at this point).
DFP will present a single Line Item section (all orders must have at least one item, though they can have more). Give the Line Item a name such as “Leaderboard run.” Click in the Inventory Sizes field and you’ll see a list of the sizes of all inventory you’ve defined so far. Select 728×90, since that’s the size of a leaderboard ad. Enter any optional comments you’d like (these could be a note-to-self, such as “Pizza banner running through March 2012″).
Now take a look at the Settings section. The “Type” you select is critical – refer back to the Order Types section of the Vocabulary page in this tutorial for a refresher. For now, let’s assume that KDMC is running a Sponsorship campaign, since that’s generally the highest-paying type of ad run. While you’re here, experiment with the Type drop-down, and notice how certain fields change depending on the type you’ve selected. For example, a Standard ad lets you set a certain number of impressions or clicks, while a Sponsorship lets you set a percentage of all impressions – this difference matches the difference in the definitions of those two terms in the Vocabulary section.
Set the Line Item to Sponsorship, starting immediately, ending one month from now, with 100% of all impressions, and a cost of $50 per day. Notice that, if possible, DFP will use this information to calculate the approximate value of this ad run as “Total Cost.” Ignore the Adjust Delivery and Add Targeting sections for now – we’ll come back to that later.
Because each Line Item must have at least one creative associated with it, clicking Save at this point would cause DFP to warn us that the order is in Draft status. Instead, click the Save And … button and select Upload Creatives.
On the next screen, DFP will ask you what kind of creative you want to add. This could be an interactive Flash file, ad code from an external ad network, or a basic Image. Choose Image.
From the file browser, select the file
kdmc-lb.jpg and give it a name. Finally, enter the all-important click-through URL – this is where users will go when and if they click on the ad. Your advertiser will provide you with the correct URL. For now, just enter http://kdmc.berkeley.edu, or any functioning URL you like. Make sure the “Target ad unit size” matches the size of the creative you’re uploading.
On the next screen, DFP will show you what the uploaded creative looks like, and ask you to Approve it – do so. This step is just confirmation, so you don’t show the wrong ad in case a mistake was made during upload.
Now you’re ready to add two more Line Items to the order, one each for the sidebar ad and the “below article” ad. Click on Orders at the left of the screen, select your order, and then New Line Item for each. Once all three line items have been added to the order, your order should look a bit like this:
Now it’s time to take a look at your site. Are your uploaded ads displaying correctly?
Unfortunately, the answer is probably no. That’s OK – there’s a good reason for that, which we’ll discover in the next section.
There are a number of things that can prevent an ad order you’ve just placed from showing up – some expected, some not. Knowing these “Gotchas” in advance can save a lot of frustration.
We’re so accustomed to having everything on the web happening in real-time, it comes as a surprise when we encounter something that’s not. But DFP is just such a system – it has all kinds of built-in delays. Some are for performance and indexing reasons, others are to prevent you from making mistakes in public. The following actions in DFP do NOT happen in real-time:
- Inventory changes: 60 minutes.
- Line item changes: 15 minutes.
- Line item impression delivery: 30 minutes.
- Line item impression reporting: 30 minutes.
In other words, it’s probably going to be half an hour before your ads appear on the site (and possibly up to an hour, in our experience). There’s nothing you can do about this – you just have to plan for it. In practice, most advertising relationships are scheduled – you want to start showing a client’s ads midnight on February 1, for example. But keep in mind that if you go back into an order or line item and tweak it, you’re going to reset that clock – so don’t keep fiddling if you’re anxious to see your changes!
Click Fraud Protection
Online ad systems grapple constantly with something called “click fraud” – the practice of inventory owners clicking the ads on their own sites to artificially pump up payments. And when they’re not clicking ads themselves, they’re paying someone else to do it. Google builds a number of protections into the system to prevent click fraud, and the most basic is “IP blocking.” Since you’re logged into the DFP control panel, Google knows your IP address, and can exclude any clicks or impressions on your ads that are generated by you.
In order to do this, Google basically makes your own traffic invisible. In other words, because clicks and impressions aren’t registered with DFP, you’ll see unexpected side-effects. For example, once an ad starts running, the status of an order as seen in DFP may not move from “Ready” to “Delivering” as expected. This problem generally only comes into play when you’re developing a site on a non-public “staging” or “development” site, since you’re the only one generating traffic on it.
While it’s technically safe to click your own ads while logged in to DFP (since your hits are excluded), don’t overdo it and don’t make it a habit – if you accidentally try it while NOT logged into DFP, you could get yourself booted from the system.
Some Error Messages Are Ridiculous
DFP includes a “debug” tool that will help you investigate exactly what’s going on as the system is deciding which ad to show in a given slot on a given page. It’s extremely useful and we’ll come back to it later, but be aware that some of the error messages it gives you can be downright misleading. For example, the message “No active right-size creative associated” sounds like it’s identified a problem with image sizes. But in fact, this is one of DFP’s catch-all error messages, and may actually have nothing to do with image sizes at all. Don’t worry – most error messages actually are helpful – not all of them are as whacky as this.
In general, pretty much anything you need to learn about DFP not covered in this tutorial can be found in DFP’s own documentation. You’ll find a link to “Help” in the top right corner, and context-sensitive help in the lower left of most screens. In addition, look for the small question mark icons next to certain interface elements – hovering your mouse over those will give you a bit of guidance.
When all else fails, use the link in DFP to the “Forum,” where hundreds of DFP users congregate and help answer each other’s questions.
One of the most powerful aspects of DFP is its ability to “target” ads at certain groups of people. For example, if you’re running a hyperlocal news site, you might want to display ads for local businesses only to visitors coming from your region – why waste all those impressions by putting them in front of people that will never become customers of those businesses? Or you might want to show a beer and pizza deal only to students from local universities and campuses.
Similarly, you might have high-bandwidth, rich-media ads that should only be shown to visitors coming in with a broadband connection. You might want to prevent Internet Explorer users from seeing ads crafted in HTML5. If you want to get really fancy about it, you might want to make sure certain ads are only shown to male or to female visitors. All of this is possible with DFP’s ad targeting system.
Targeting parameters are attached to Line Items, and can be set either while placing ad ad or added on later. Let’s return to one of the line items we’ve already created and set some targeting criteria. Click on Orders, then My Orders. Click on an order name, then click one of the line items within it. Finally, click the Settings tab within that Line Item.
At the bottom of the Settings panel, you’ll find an Add Targeting section.
Along the left side of the Target section, you’ll see a list of targeting categories: Inventory, Custom, Geography, Browsing, and User Domains. The box on the left lets you sort and filter for various criteria, and provides small “add” links.
Clicking on one of these links causes that criteria to appear as a list in the box on the right.
This is your list of final serving criteria for the line item. Click the small “x” to remove a criterion from the list.
In most cases, you’ll want to start with the Inventory selector, and define an Ad Unit in which the Line Item should run (otherwise it is possible the item could appear in other ad units on your site for which its eligible for other reasons.)
Let’s skip Custom Criteria for now, and move on to Geography. Try typing in a zip code or city name, then click Find. DFP will locate the region on Google Maps and let you check one or more boxes to select an area. Click the “add” link and that regional criteria will appear in the right-hand Selected Criteria box.
Note also the “Matches” drop-down near the top. This is present in all of the selectors, and can be changed to “Does not match.” If you want to serve one ad in a line item to users in your geographical area and another to everyone else, just create two line items, then use the Matches / Does Not Match picker to select which ads are shown to whom.
The Browsing selector works similarly, but lets you precisely target your ads to particular web browsers, such as Firefox, Internet Explorer, Safari or Chrome. You can even drill down to specific browser versions if you happen to use an ad technology that doesn’t work in certain browsers (Internet Explorer 6 is particularly problematic for modern web technologies, for example).
The User Domains selector works exactly as advertised – it lets you target ads to users visiting from specific domains. This is particularly useful for targeting university students (just enter “berkeley.edu” for example).
Click Save, wait a while, and your targeting will kick in. If you want to test targeting for yourself, a good way is to target one line item at Firefox users and another at all other browsers. Then try visiting your pages with Firefox and with another browser – you should see different ads.
Web browsers don’t know the gender or age of users, but if a user is currently logged into your site, your CMS may well know these things. By passing this value to DFP through a semi-hidden parameter, DFP can become aware of any sort of custom criteria you define. Let’s try a simple gender matching key.
Before you can use custom criteria, you’ll need to define them. Leave the Line Item settings and go to the DFP Inventory tab, then click Custom Criteria.
Click “New Key” and enter the name “Gender.” Select “Users will select from predefined targeting values.” Enter the words “male” and “female” into the values field (one per line) and click Save.
Once your custom criteria have been defined, return to the Line Item settings, choose Custom Criteria, and select your custom key from the list.
Since DFP lets ads compete in real-time with one other for highest-paying placements, and because there are so many criteria involved in deciding which ad wins a placement on any given page load, you can imagine that the algorithms involved can become extraordinarily complex. Trying to figure out why a given ad did or did not “win” this real-time competition can be tricky.
Fortunately, DFP provides a “debug” mode which can help you figure out exactly what DFP was thinking on a particular page load. To activate debug mode, just append the parameter
?google_debug to the end of your URL. For example, if the page you’re looking at is:
then make the URL read:
If there’s already a question mark in the URL, use standard URL parameter technique to add the parameter. For example, if you already have:
You’ll need to enable popups in order for anything to happen – most modern browsers block popups by default, and all provide the options to selectively allow them in different places.
Google Chrome: Click the small box with the red X in the OmniBar, then click the Loading link.
Apple Safari: Pull down the main Safari menu and disable the option “Block Pop-Up Windows.”
Mozilla Firefox: In the yellow bar that appears at the top of the browser window, click Preferences, then select “Allow pop-ups for domain.com.”
The DFP debug window will pop up, and present you with a long list of technical stuff. At the top of the window, you’ll see a list of Ad Units (Ad Slots) that were invoked on the current page. To the right of each, you’ll see a Details link. Click the one you’re curious about.
At the top of the resulting window, you’ll see the Winning Line Item, followed by a list of Rejected Line Items and the reasons for their rejection.
In this example, we see that one line item was rejected for being of a “lower priority” (it was selling for $20/day, while the winning item was $50/day). We also see another line item rejected for the dreaded catch-all reason “No active right-sized creative associated.” Remember, this message doesn’t necessarily mean your ad art is of the wrong size – it could mean almost anything. In many cases, items in this bucket are rejected because they’re still in Draft mode, or because their inventory has been released, or because they have a $0 CPM associated with them, or other reasons.
You may still need to do a bit of sleuthing to figure out exactly why line items get rejected, but debug mode will generally put you on the right track.
About this Tutorial
This tutorial was written for KDMC’s Independent Journalists workshop series, but is applicable to anyone getting started with Double-Click for Publishers.
This content may not be republished in print or digital form without express written permission from KDMC. Please see our Content Redistribution Policy at kdmc.berkeley.edu/license.