Is there an AJAX service for doubleclick (DART)

2020-06-05 01:53发布

问题:

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>