In this article with video tutorial you will learn how to implement Google DoubleClick for Publishers (DFP) into WordPress using Advanced Ads.
I am also going to cover the disadvantages of the separation of header and body tags and how to solve them.
Video (9:26 min)
Setup used in this tutorial
- Advanced Ads, version 22.214.171.124, Download for free
- DFP: Generate ad tags in DFP
- How to create and display your first ad with Advanced Ads
- Debugging DFP (see below this article)
Inserting Google DFP into WordPress
DFP is a powerful web server used for serving ads to end users. It is especially useful for tailoring by geolocation and other demographics. Throughout the rest of the article, we will assume you are already using this function and know how to use Google DFP tags and how to get them.
A Google DFP tag is not a single tag as it is on AdSense. It has a header tag and a tag for the ad unit. The header tag contains information about the loaded ads, including their unique IDs, information that we will need in this tutorial.
In order to set up DFP, we need at least two ad units. The first is for the header tag and the second for each ad.
Go to Advanced Ads > Ads > Create New Ad
Give your ad a title. We called ours “DFP Head”. Select ad type “plain text and code” if it is not already pre-selected.
Bring up the code again and copy the header tags from the code box and paste it into the box marked Ad parameters. Typically, you will not need to change anything else so you can publish that ad immediately.
Next go to Placements on your dashboard and click Create New Placement. You will need to assign it a certain type. The text you just copied was header text so select the header type. Don’t forget to give it a name, then choose the ad or group and save.
The header code should now be on the website.
Next, you will repeat the process for the ad codes and put them in the front end. Go to Add New Ad, give the ad a name. In this case, we call it “Skyscraper”. Copy the text from the ad code list – do one for each individual ad, copying only the ad text. As you can see in the image below, we have copied over the short tag´referring to the skyscraper ad only. We place this in the ad parameters box in the WordPress client on the left hand side of our screen.
We use fake numbers so we cannot show you how the ad should look, it is just an example.
Then click publish to complete the action. You should check them on your website to make sure they look right – for example, placing them in the widget area of WordPress or on a sidebar or wherever else you are placing your ads.
Matching Header and Body Code
We’d like to take a brief moment to demonstrate a problem with DFP. Imagine you have just published an ad on your WordPress CMS. The header tags preload the ad content; this is useful because when the ad content is added later, it loads much faster than it would if it was just loaded as a separate ad.
The problem is that Google DFP believes when you preload the ad in the header content, that it ought to display it which means they already count the impression in the DFP server. If you mix up the numbers, you will see nothing. Make sure the tags matches between the ad ID in the header tags and the ad ID itself.
What if you want to display one ad on all websites but a second just in one location or in a specific category? Not a problem, all you need to do is create two header units in Advanced Ads as described above.
Create one for the condition for both ads to be displayed, then a separate ad unit. For example in the image below, we have created the header ad but removed the ad that will only appear in one place – just one appears in the text.
Before publishing it, create a group (on the right of the above image, text is entered into the Ad Groups area). Return to any other ads and add it to the group you just created (if necessary). Then go to Placements in your sidebar and under DFP Header change the option to group from ads.
This ensures that only one header is selected at any one time.
Next, create a group for the ad that you want to appear only in one place. Don’t publish the group, simply copy over the tags from the ad and then scroll down to Display Conditions. Change from Display Ad Everywhere to Set Display Conditions. A series of options will appear.
In our case, we have chosen to display in the “General” Category so uncheck the “display all categories, tags and taxonomies” as displayed in the image above. When unchecked, it should look like the image below.
Click “General” or whichever category you want it to display in. Once this is done, you can publish it. By all means check again that the ad is displayed properly but most importantly, you need to check that the group does not contain the ad that you want to omit. Go back in the ads and double check.
Note: ensure that the header also has the same display conditions
Defining the Order
Go to Advanced Ads > Groups
You can see on the right hand side that under ads in the image above (right hand side) there is an ordered list. It is important to ensure that the header code with the most restrictions is loaded first. We use the second one with the two ads in as a fall back should anything not function properly.
Check the one with the conditions. Click edit on the left hand side and the screen should look like this.
Click on Ordered ads. At the bottom of the screen, you will see that the ads are ordered. In the image above, both have been set to 10. We only have two options, so we set the one that needs to be checked last to “9” (DFP Head in our list). The highest number always runs first. Anything set to “1” will always come last. It is important to remember this.
Then save it and you are done.
Debugging DFP ads
Especially when getting started with Google DoubleClick, ads sometimes stay blank for no obvious reason. Publishers might not know in this case whether it is related to the setup in DFP or Advanced Ads. Therefore, we introduced the “debug DFP ads” item in the “Ad Health” menu in the admin bar in the frontend. When you click on it, the “googfc” parameter is added to your URL and the page is reloaded. If the DFP code is implemented correctly, you will see overlays and additional windows on the screen. If you don’t there is a problem with the implementation through Advanced Ads.
The DFP debug output will stay visible to you until you close it.
The best way to use Google DFP is to have the same ad units on all sites. It’s easier if you have them in the header or sidebars but in some cases, you will need to break them up as we explained in the second half of the article, to create different ad setups.
This is to avoid the problem months later when you notice your click through rates are lower than they should or could be – the problem being that your ad unit is counted too often, more often than it is displayed. It is a problem with Google DFP, but Advanced Ads can help you to solve it like explained above.