New Plugin — Easier DoubleClick Ads for WordPress

This week we’re happy to announce a new WordPress plugin to make serving DoubleClick ads easy.

In the past we’ve used (and will continue to use) Automattic’s ad code manager to control ad tags. This plugin comes with a plethora of options, including support for different providers. While its fine for some users, for most of our applications it’s downright unwieldy.

We designed our plugin to be lighter-weight and to work out of the box with as little setup as possible. The minimum needed to start serving ads is to define your network code and place a widget in a sidebar. Then you set options for the DFP identifier and size of the ad spot and that’s all there is to it.

Responsive ads

It’s easy to serve different size creatives at different breakpoints. For example, in a leaderboard spot, it’s possible to add one widget to display 300x50 sized creatives on mobile and 728x90 size creative on tablets and desktops. Only one will be loaded and counted as viewed in DFP, depending on the breakpoint.

Targeting

This plugin sends information about the page to DFP to make targeting specific sections and pages of a site easy.

  1. inURL: Target a piece of the page path. (eg. targeting the string /dvd would match example.com/dvds/, example.com/dvds/page1 and example.com/dvds/page2)
  2. URLIs: Target the entire page path. (eg. targeting the string /books will only match example.com/books and not example.com/books/page1)
  3. Domain: Target based on the domain. (eg. run different advertising on staging.example.com and example.com.)
  4. Query: Target a ?query var. (eg. target the url example.com/?movie=12 with the targeting string movie:12)

See the documentation for more information on how to set these values up in DFP. We’ll be adding targeting criteria for post category, post type, template type and other criteria specific to WordPress in the future.

Theming

If you don’t maintain widget areas in your theme, you can hard code breakpoints and places ad units directly in your template files.

Defining breakpoints is simple. We suggest you do this for users in your theme’s functions.php since most users will not know pixel values for the theme's breakpoints.

function ad_setup() {

   global $DoubleClick;

   // Optionally define the network code directly in functions.php.
   // $DoubleClick->networkCode = "xxxxxxx";

   /* Define Breakpoints */
   $DoubleClick->register_breakpoint('phone', array('minWidth'=> 0,'maxWidth'=>720));
   $DoubleClick->register_breakpoint('tablet', array('minWidth'=>760,'maxWidth'=>1040));
   $DoubleClick->register_breakpoint('desktop', array('minWidth'=>1040,'maxWidth'=>1220));
   $DoubleClick->register_breakpoint('xl', array('minWidth'=>1220,'maxWidth'=>9999));

}
add_action(‘dfw_setup','ad_setup');

To place an ad in a given location, just call place_ad on the global $DoubleClick object.

   // Places a 728x90 leaderboard ad for all breakpoints but mobile.
   $DoubleClick->place_ad(‘site-leaderboard','728x90',array('desktop','xl','tablet'));

That’s it. We’re excited to see how you use it! Download the plugin from Github here.