Is there an AJAX service for doubleclick (DART)

谁都会走 提交于 2019-12-04 15:04:25

问题


I'm trying to put some ads on my site and would like to load them after the page has loaded. We're using Doubleclick DART (please, don't tell me to use Google AdSense. I know, but that's a battle for another day). Doubleclick currently recommends embedding inline script tags like so:

<script language=Javascript1.1 src="http://ad.doubleclick.net/adj/sitename.dart/ 
zonename;abr=!webtv;kw=value;sz=widthxheight;ord=value"> 
</script>

This returns a document.write with the ad html.

Does anyone know of a way to request the ads with an AJAX call so that only HTML is returned, thus allowing me to place the ads at my discretion? I've seen this done for mobile ads, but haven't found anything for websites yet.


回答1:


I eventually resolved this using a script called writeCapture. It intercepts the document.write event on ads and lets you perform the HTML append.

The documentation on the site is great, and you can see it in action on The Daily Beast.




回答2:


You should be able to replace "adj" (Ad JavaScript) with "adi" (Ad IFrame) in your script URL to get the HTML. After you make that change you can inject the script after page load by dynamically creating an iframe element, setting the source to the script URL and appending it to the DOM.




回答3:


I wrote an extension using jQuery to inject DoubleClick ads into a page after page load. You can find it at jquery-doubleclick-ads - Google Code and it is currently in use on the www.ourbrisbane.com site.




回答4:


you can also utilise /adx/ which tells doubleclick to return the ad in its original form (whether HTML / js tags etc) without wrapping it in document.write or an iframe.

But note google may not 'officially' support any issue this may cause but through experience there not many ways this can go wrong outside of your ad script




回答5:


You can AJAX it in like so

<script type="text/javascript">
    var ord = Math.random();
    ord = ord*10000000000000000000;

    jQuery.ajax({
        url: "http://ad.doubleclick.net/adj/sitename/homepage;pos=1;ord='+ord+';sz=300x600,300x250,160x600",
        cache: false,
        dataType: "html",     
        success: function(html){
            $("#mysAd").append(html.split("'")[1]);
        }
    });
</script>


来源:https://stackoverflow.com/questions/1532093/is-there-an-ajax-service-for-doubleclick-dart

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!