Webmasters Stack Exchange is a question and answer site for pro webmasters. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to use DFP for my ads. To display an ad I am calling GA_googleFillSlot(). My understanding of this is, that this function injects the ad code at the position where the JS call is placed. How can I detect if the placement is empty, e.g. no banner code will be injected because there is currently no banner. I need to know because the surrounding html needs to be adapted. Any ideas?

Alternatively, is it possible to alter the injected html elements? DFP injects a div with id="google_ads_div_$PLACEMENT_ID">. Is it possible to add a class attribute?

share|improve this question
up vote 2 down vote accepted

Using JavaScript, you can use the .innerHTML attribute to see if there is any HTML inside of the div after the GA_googleFillSlot().

And yes, the div tag supports both id and class attributes: click.

For coding questions similar to this, please direct them to Stack Overflow.

share|improve this answer
It is not really a programming question, but a question about integration of a webservice. – EricSchaefer Feb 20 '11 at 16:15

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.