-1

I got a page which has 8 doubleclick AD blocks and sometimes the given AD parameters don't have ADs to serve from doubleclick, is there a way to detect if ADs are served and prevent further doubleclick js loads?

{% for ad in 123|make_list %}
        <div id="ad_618_50_{{ad}}">
            <script type="text/javascript">
                    document.write("<script type='text/javascript' src='http://ad-apac.doubleclick.net/Nxxx6/adj/xxx_2011/platinum;tile=1;cp={{results.doubleclick_category_id}};lp={{results.doubleclick_region_id}};kw={{results.doubleclick_category_name}};pos=box{{ad}};sz=618x50,618x110;;ord=88xxx4590xxx98461023?'><\/script>");                        
                </script>
        </div>
{% endfor %}
James Lin
  • 25,028
  • 36
  • 133
  • 233

1 Answers1

0

OK, I have implemented a hack which uses javascript to detect if a div has been added by doubleclick script, if not then set a variable flag to disallow consecutive doubleclick js to load

    {% for ad in 123|make_list %}
    <div id="ad_618_50_{{ad}}">
        <script type="text/javascript">
            if (typeof platinumAds === "undefined") {
                platinumAds = true;
            }
            if (platinumAds) {
                document.write("<script type='text/javascript' src='http://ad-apac.doubleclick.net/Nxxxx/adj/xxx.co.nz_2011/platinum;tile=1;cp={{results.doubleclick_category_id}};lp={{results.doubleclick_region_id}};kw={{results.doubleclick_category_name}};pos=box{{ad}};sz=618x50,618x110;;ord=xxx3014590xxx461023?'><\/script>");
                }
            </script>

        <script type="text/javascript">
            if (!$('#ad_618_50_{{ad}} > div').size()>0){
                platinumAds = false;
            }
        </script>
    </div>
    {% endfor %}
James Lin
  • 25,028
  • 36
  • 133
  • 233