Git Product home page Git Product logo

async-dfp-ads's Introduction

Read background info at : http://www.sajalkayan.com/complete-asynchronous-ad-loading-using-dfp-and-labjs.html

Usage:-

Following variables need to be prepopulated.

1) DFPpubid = "ca-XXXXXX" - where XXXXXX is your adsense publisher id as seen on top right corner of adsense pages
2) adslots = An array with adobjects for ad locations

`
var DFPpubid = "ca-XXXXXX";
var adslots = [{"pubid": "ca-pub-XXXXXX", // pubid again
  "slotname": "test_async_lb", // ad unit name from DFP
  "width": 728, // width of ad unit
  "height": 90, // height of ad unit
  "target": "leaderboard" // id of the <div> to be populated with the ad
  }, // repeat for as many ad units needed
  {"pubid": "ca-pub-XXXXXX",
  "slotname": "test_async_sky",
  "width": 160,
  "height": 600,
  "target": "skyscraper"
  }];
`

After the above 2 variables are populated, include the script using LABjs

    $LAB.script("dfp-lab-iframe.js").wait(function(){
      DFPasync(adslots, DFPpubid);
    })


Warnings:-
1) Requires LABjs to be loaded - http://labjs.com/
2) Uses DFP's iframe method, so no expandable ads - http://www.google.com/support/dfp_sb/bin/answer.py?hl=en&answer=90777
3) This is a hack. If DFP changes their ad loading mechanisms this may break your site.
4) I don't confirm or deny if this script voilates any TOS.
5) Goto 1)

document.write is evil. It must die!

async-dfp-ads's People

Watchers

James Cloos avatar Rahul 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.