JavaScript event when ads are loaded using Advanced Ads Pro

We provide the code snippets and content on this page without any guarantee or support. In most cases, these pages are created on requests or based on individual solutions sent to us by other users. After it was published, we are only reviewing the code and content when we are made aware of an issue. Please let us know if you find one.

Please only use the codes if you understand them and know how to add custom code to your WordPress site.

The following JavaScript code allows you to do something as soon as Advanced Ads Pro finished loading ads.

if ( typeof advanced_ads_pro === 'object' ) {
  advanced_ads_pro.observers.add(function(event) {
      // Note: These events may be triggered multiple times
      // because not all ads are injected at the same time.   
      // The injection may be delayed by the lazy load feature or the group refresh feature.
      if (event.event === 'inject_passive_ads') {
        console.log(event);
      }
      if (event.event === 'inject_ajax_ads') {
        console.log(event);
      }
      if (event.event === 'inject_placement') {
        console.log(event);
      }
    } );
}

Make it better

Increase your ad management skills without spending more time.
Join over 150,000 publishers and AdOpts increasing their ad revenue.