How To Detect Loading State Of A Google Doubleclick For Publishers Dfp Ad?
We have a series of DFP ads on a page that get refreshed automatically using the javascript refresh() call each time a user clicks each thumbnail icon on a gallery viewer: googleta
Solution 1:
I made a jquery plugin that wraps DFP and kind of came up with a solution to this problem a while back... there is an internal function on the ad unit called renderEnded() that you can hook into to check when the ad unit has been rendered.
In my experience this just means that the HTML code has been put into the page... and not necessarily that the ad has completely finished loading. You could combine some timeOuts with this to get a fairly robust system going though.
For example with my plugin you can try the following, it shouldn't allow ads to be refreshed until 5 seconds after the last ad on the page has rendered:
<!DOCTYPE html><html><head><title>TEST</title><scriptsrc="http://code.jquery.com/jquery-1.9.1.min.js"></script><scriptsrc="http://coop182.github.io/jquery.dfp.js/jquery.dfp.js"></script></head><body>
Test DFP Ads.
<divclass="adunit"id="buyingcars_ATF_728x90"data-dimensions="728x90"></div><script>var adsLoaded = true;
functioncheckLoading() {
console.log('Checking...');
if (adsLoaded) {
loadAds();
}
}
functionloadAds() {
console.log('Loading...');
adsLoaded = false;
$.dfp({
dfpID: '3853655',
afterAllAdsLoaded: function() {
setTimeout(function(){adsLoaded = true;}, 5000);
}
});
}
checkLoading();
</script><ahref="#"onclick="checkLoading();">Refresh</a></body></html>
Post a Comment for "How To Detect Loading State Of A Google Doubleclick For Publishers Dfp Ad?"