Integrating DoubleClick for Publishers into WordPress
When building my new site, I wanted a professional solution for my ad management. I wanted to do more than just AdSense ads, as well as combining ad units into topic based bundles for better targeting.
I’d heard of DoubleClick for Publisher (DFP) before. DFP, bought by Google in 2008, is free if you’re serving less than 90 million impressions per month. You are then using the Small Business edition, and that version is used for this tutorial.
My site is built on WordPress, and integrating it requires a few steps for it to work. That is, if you want to get the same method of targeting I used on my own site. I will first explain what I tried to achieve, and in a screencast I will show you how it’s done.
My site is divided into several different topics, like security officer jobs or passenger service agent jobs. It’s a so-called niche site. For most topics I have both a job description page, and a separate page with vacancies. I wanted these two pages to allow the same targeted ads.
I also put up an article series for air hostess jobs (have a look to see what I mean), consisting of five pages. The whole series should have the same targeting possibilities. The article targeting allows for in-content ads (468×60) and a large 300×600 unit in the sidebar, and there are also two run-of-site ad units (728×90 header and 300×250 sidebar) set up around the content.
Have a look at the linked pages to get the idea. In the screenshot below you can see the ROS ads outlined in red, and the targeted ads outlined in blue.
The little marks in the left corner with the size displayed within are generated by the Google Publisher Toolbar, which will be shown in the screencast.
So far the idea seems pretty clear and easy, but there are a few hurdles to overcome:
- For optimal reporting, each targeted ad needs it’s own unit in Google DFP.
- Every targeted unit on a page needs to be combined with the other units on that page into an ad zone.
- Ad code needs to be implemented within the content, something WordPress isn’t too fond of.
- For the sidebar ads to be targeted you need to be able to add custom sidebars.
- The header ad is something which is built-in in most templates. If not, this needs to be coded in (not included in this tutorial).
- Google DFP uses a lot of code for each ad unit, some of which needs to be inserted into the of each page.
The following screencast will take you through all these steps. I will show you how to:
- Generate ad units in Google DFP, and combine these into ad placements
- Generate Google DFP tags (ad code), and implement this in the body of your site (in-content, sidebars and header)
- Insert the relevant code into the each
In this screencast, I made use of the following theme, plugins and services:
- Code Insert Manager: Used for inserting code in the head of a page
- Custom Fields Shortcode: Used for inserting code in the body of a page
- Custom Sidebars: To be used if your template doesn’t allow you to add custom sidebars. Not used in this tutorial
- Duplicate Widget: Used to set up Run of Site ad code in one sidebar widget, and use the same code in other sidebars. This way you only need to change one widget
- Google Publisher Toolbar: Used for checking your ad units on-page