Q&A
Mr. Pickles the AdPlugg Pug

AdPlugg API to check if there is ads visible

+1
0
-1

Hi,

I am just wondering if there is a javascript API where we can check if there is an ads displayed in a particular zone of a page.

The reason for this is because for each ads zone, we will display the fine print text with the word "advertisement" on top of the designated ads zone. Ideally, we don't want the "advertisement" text to be visible if the ads zone below it is not serving any ads at the particular time instance.

We were thinking if there is an API where can call to check the ads visibility status where we can then show / hide theĀ "advertisement" text accordingly.

If there is no API for this, I would appreciate any workaround solution for this.

Thanks!



Answers

+1
0
-1

You can do this using the AdPlugg JavaScript SDK's event system and AdPlugg.on().

Listen for "adplugg:renderStart" events and show your "advertisement" text in the callback function. We don't have much for documentation for the AdPlugg.on() feature yet but you can see an example of how to use it in our AMP implementation (https://github.com/ampproject/amphtml/blob/master/ads/adplugg.js).

Note that for AMP we are doing the following:

  • Loading theĀ https://www.adplugg.com/serve/js/ad.js script. This script is slightly different than the one that currently comes down with the AdPlugg Snippet in that it doesn't autorun.
  • We then programatically create an AdPlug Ad Tag and insert it in the DOM.
  • We then register event listeners on the tag.
  • Lastly we call AdPlugg.run (via the lazy loading command queue).

Also note that AdPlugg.on() is based on jQuery's on function, we just added a selector parameter as the first parameter. For this parameter you can pass in a jQuery object, jQuery selector string or a DOMElement.

AdPlugg.on() currently supports the following events:

  • adplugg:renderStart
  • adplugg:renderEnd
  • adplugg:noContentAvailable

Hopefully we'll have more complete documentation for AdPlugg.on() and other advanced features of the AdPlugg JavaScript SDK soon.