Code Monkey home page Code Monkey logo

dfp-events's Introduction

dfp-events

For use with Google's Doubleclick for Publishers (DFP). Taps into dfp's logger function and triggers events.

Methods:

googletag.on()

googletag.on(events,data,callback);
  • events - string containing a list of events to bind to.
  • data - (optional) data to be passed to the callback upon triggering, passed via arguments[0].data a la jQuery.
  • callback - function to be called upon one of the events occuring.

googletag.off()

googletag.off(events,callback);
  • events - string containing a list of events to remove callbacks from.
  • callback - (optional) specific callback function to be removed from googletag.

Events:

  • gpt-google_js_loaded
  • gpt-gpt_fetch
  • gpt-gpt_fetched
  • gpt-page_load_complete
  • gpt-queue_start
  • gpt-service_add_slot
  • gpt-service_add_targeting
  • gpt-service_collapse_containers_enable
  • gpt-service_create
  • gpt-service_single_request_mode_enable
  • gpt-slot_create
  • gpt-slot_add_targeting
  • gpt-slot_fill
  • gpt-slot_fetch
  • gpt-slot_receiving
  • gpt-slot_render_delay
  • gpt-slot_rendering
  • gpt-slot_rendered

Examples:

Notice I use jQuery to cause changes to the DOM but not to bind or unbind the callbacks to the googletag object.

Bind callback to a DFP event

googletag.on("gpt-slot_rendered",function(e,level,message,service,slot,reference){
	var slotId = slot.getSlotId();
	var $slot = $("#"+slotId.getDomId());
	
	if($slot.find("iframe:not([id*=hidden])").map(function(){return this.contentWindow.document;}).find("body").children().length == 0)
		$slot.addClass("empty");
});

Remove binding

googletag.off("gpt-slot_rendered");

dfp-events's People

Contributors

mcountis 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.