mcountis / dfp-events Goto Github PK
View Code? Open in Web Editor NEWFor use with Google's Doubleclick for Publishers (DFP). Taps into dfp's logger function and fires triggers events using jQuery.
For use with Google's Doubleclick for Publishers (DFP). Taps into dfp's logger function and fires triggers events using jQuery.
I noticed you haven't declared any license, yet, can you clarify it?
Hello,
I'm an engineer at Google, on the team that maintains gpt.js. Please do not use this library, or rely on hooking into googletag.event_log
in any way. It's being removed as part of a code cleanup our team is doing. Any code accessing that property will likely break, since that key will no longer exist.
googletag.event_log
is not a public API, and was never meant to be used as such. See the supported API docs here.
Here is the list of events which we officially support:
If you have a use case which is not supported by any of these existing events, please file product feedback using the "Send Feedback" button (located in the upper-right corner of our docs page)
Such as "SummerPromo_Midscale_160x600_stdfla_20130508.swf". No the slot name but the name of the ad creative that might appear in the slot?
Hi and thank you for this code.
I just set it up on my development environment, and I was very excited to see it working on Firefox!
But when I tested on Chrome and IE8, the events were not firing. This is how the whole of my DFP related JS looks like:
googletag.cmd.push(function() {
var arr = document.getElementsByTagName('div');
for (var i=0; i<arr.length; i++)
{
if (arr[i].className == 'gpt-ad')
{
var slot_name = arr[i].getAttribute('slot_name');
var id = arr[i].getAttribute('id');
var width = parseInt(arr[i].getAttribute('width'));
var height = parseInt(arr[i].getAttribute('height'));
var targeting_key = arr[i].getAttribute('targeting_key');
var targeting_values = arr[i].getAttribute('targeting_values').split("|");
googletag.defineSlot(slot_name, [width, height], id).addService(googletag.pubads()).setTargeting(targeting_key, targeting_values);
}
}
googletag.pubads().collapseEmptyDivs();
googletag.enableServices();
var arr = document.getElementsByTagName('div');
for (var i=0; i<arr.length; i++)
{
if (arr[i].className == 'gpt-ad')
{
var id = arr[i].getAttribute('id');
googletag.cmd.push(function() { googletag.display(id); });
}
}
if (googletag.on !== undefined && $ !== undefined) {
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.closest('.advertisement').show();
}
});
}
});
My ads are in a container called ".advertisement", and it's display:none
by default. Then when an ad is rendered, I'm calling .show()
on it.
This is because I don't want to display an empty box when there's no ad booked, and I don't have house ads to run.
Anyway, this works great in Firefox, but when I checked in Chrome, the event wasn't firing. I put a breakpoint at $slot.closest('.advertisement').show();
and nothing happened. Same in IE8.
Could you please help me figure out what's wrong?
Thank you!
i have a page with alot of dfp tags in him but just 3 of them are firing up.
what seems to be the problem?
Hi,
is there any possibility to listen ImpressionViewable.
I have try to follow #4 to found a relevant ID for this event, but i don't find any usefull information.
Thanks.
Hey guys,
It seems calling the extended googletag.debug_log.log() method gets called once and then never again in browsers <= IE8
Any ideas, anyone else seen this?
Is it possible to get the loading time and rendering time of creatives in the page using gpt-slot_render_delay
or gpt-slot_rendering
events ? I have totally four adunits in the page. I wanted to log all the adunit's rendering and loading response time similar to google publisher console's ?googfc
does.
Your code is great -- very clever solution; thank you for sharing it. We're using it to manage the visibility of responsive ad units. At different breakpoints we load different ad sizes, and we hide/show them as appropriate. To keep the number of impressions down (and keep the payload down for the user), we defer the loading of the various ad sizes until they're needed, but GPT forces the visibility of the ad after the async load is complete, which interferes with our visibility management code. Tapping into the rendered event is a perfect way to maintain control over which ad is showing at a given breakpoint!
Events should be built into GPT -- have you spoken with anybody at Google about that? My biggest concern is how fragile this all will be if Google changes their logging tomorrow or next week.
Shouldn't line 113:
if (!message && typeof (message.getMessageId()) !== 'number') return;
use || instead of && ?
if (!message || typeof (message.getMessageId()) !== 'number') return;
Hi,
Yesterday I start getting this error at this line:
if(message.search(events[e].match) > -1)
I printed the object "message" and there is no "Search" function available.
Please help.
Thank you in advance.
useful enhancement to DFP. any chance we can see this on npm? would be easier to manage that way as a 3rd party dependency rather than copying alongside application code.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.