JavaScript API

The Adtoniq JavaScript API provides a callback mechanism for your JavaScript code so that you can be alerted of various Adtoniq events. The following functions are available:

addAdBlockerCallback

The addAdBlockerCallback function is used to add a callback function when an ad blocker is detected. The function is passed three parameters which are all booleans:

  1. isNetwork indicates whether the ad blocker blocks network connections to ad services
  2. isElemHiding indicates whether the ad blocker hides or collapses ad units
  3. isAcceptable indicates whether the ad blocker is configured to allow acceptable ads
<script>
 if (typeof(adtoniq) != "undefined") adtoniq.addAdBlockerCallback(
 function(isNetwork, isElemHiding, isAcceptable) {
 if (isElemHiding)
 document.getElementById('elemhiding').style.display='none';
 if (isAcceptable)
 document.getElementById('accads').style.display='none';
 });
 </script>
 

The script shown above is used to update the two lines below. View the source code of this page to see how the DOM structure is set up for this.

You do not have acceptable ads enabled.
You do not have element hiding enabled.

dom

addNoAdBlockerCallback

The addNoAdBlockerCallbackfunction is used to add a callback function when no ad blocker is detected. The function is passed no parameters.

<script>
 if (typeof(adtoniq) != "undefined") adtoniq.addNoAdBlockerCallback(function() { console.log('No ad blocker in use'); });
 </script>