Git Product home page Git Product logo

dfp-ad-templates's Introduction

DFP Templates

Repo containing code to render templates/ads/splashes with variables provided from within DFP. This repo is designed so that the template code is version controlled while allowing DFP to manage only the variables passed into the templates.

Building

To build:

npx webpack

# or

yarn build

To serve:

npx webpack-dev-server -w --disable-host-check --host=0.0.0.0 --mode development --open --hot --history-api-fallback

# or

yarn serve

Templates

The /src/templates directory contains the top-level templates. These will map one-to-one with "creative templates" that exist in DFP. Currently there are two templates:

  • Desktop and Mobile Splash
  • Desktop Splash, Mobile Inset

Also coming soon is a Desktop and Mobile Inset template.

Desktop and Mobile Splash

This displays an 800x600 overlay/splash on desktop widths (> 840px), and a 240x400 overlay/splash on mobile devices.

Desktop Splash, Mobile Inset

This also displays an 800x600 overlay/splash on desktop widths, but on mobile devices it displays an inset (i.e. a 100% width block that typically will be appended to the top of the page).

This particular inset uses a 400x240 image and has a background color for widths lower than 840px but higher than 400px, where the background behind the image will be visible.

Implementation With DFP

These DFP templates are used with "Creative Templates" in DFP, which are found in Delivery -> Creatives -> Creative Templates.

To pull in a template, you need three things:

  • The required variables for the template you're using (contained within a script)
  • A div with an ID of dfp_splash_app that the bundle code will be injected into.
  • A script tag pulling in the js bundle this repo produces

As an example, here is the current Creative Template code for the Desktop and Mobile Splash template:

<script type="text/javascript">
  window.DFP = {};
  window.DFP.imageUrlDesktop = "[%DesktopImage%]";
  window.DFP.imageUrlMobile  = "[%MobileImage%]";
  window.DFP.clickthroughUrl = "%%CLICK_URL_ESC%%[%ClickthroughURL%]";
  window.DFP.templateName    = "desktop-splash-mobile-inset";
</script>

<div id="dfp_splash_app"></div>
<script src="https://demo-static.nypr.org/dfp-ad-templates/bundle.js" type="text/javascript" defer></script>

dfp-ad-templates's People

Contributors

mike-hearn avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.