Press enter to see results or esc to cancel.

Ad Blocking Detection

The plugin supports multi-level ad blocking detection that is hard to avoid. You can’t force to show the ads that were blocked, however, you can show pop up message, redirect visitor to a static page with some information or (PRO only) replace ads with a different type that will not be blocked or protect (hide) the content.


Ad blocking or ad filtering is a type of software, that can remove or alter advertising content from a website – banners, text ads, pop-ups, tracking code, malware, etc. Ad blockers are available for a range of computer platforms, including desktop and laptop computers, tablet computers and smartphones. A variety of methods have been used for blocking advertisements. The benefits of ad blocking software as seen from the visitor’s perspective are mainly reduced page loading time and ad-free web pages. Some use ad blockers also to prevent tracking scripts to collect data.

The use of ad blocking software is increasing. However, many media owners (publishers) rely on advertising to fund the free content that they provide to users. Some have already taken counter-measures against users who block ads on the sites they visit. More and more websites are asking (or sometimes requiring) visitors to turn off ad blockers before allowing them to view the site’s contents.

In most cases it is possible to detect if the visitor is using ad blocking software. However, it is not possible to force to show the ads that were blocked. But if you know that the user is using ad blocking you can do few things: you can ask him to turn it off, you can redirect the user to some page explaining the problem,

PRO You can also hide or modify the content if ads are not shown and you can replace normal ads that were blocked with some replacement ads that will not be blocked.

Ad Blocking detected – possible actions with Ad Inserter:

  1. Show popup message – user can close the message and continue reading
  2. Show popup message – user can’t close the message – navigation not possible
  3. Redirect to some page explaining the problem
  4. Show popup message with a link to a page explaining the problem
  5. PRO Replace ads with some other content or different ads
  6. PRO Protect (hide or modify) the content

PRO Ad Blocking Statistics

Ad Inserter Pro supports also ad blocking statistics. Check Ad Blocking Statistics and Pageview Tracking for details (PRO only).

ad inserter statistics adb charts

Ad Blocking Detection Settings

The settings for ad blocking detection are divided into 3 parts:

  1. Ad blocking detection
  2. General actions when ad blocking is detected
  3. PRO Actions for individual code blocks and content

Ad blocking detection is a code that is inserted when ad blocking detection is enabled. It checks various scripts and insertion of dummy ads and determines if ad blocking is present or not. Of course, this detection is not 100% reliable but it is very robust and hard to trick. There will always be some way for users to trick websites they are not using ad blockers – this is an endless game. However, in most cases it will be possible to detect if ads were blocked or not.

Ad blocking detection needs to be enabled for any ad blocking action to work. Ad blocking detection settings are available on the tab / tab Ad Blocking.

To enable Ad blocking detection click on the right button to turn it green.

Ad blocking detection needs to be enabled even if you will not use general actions available here (popup message or page redirection) but you will only replace ads or protect content.

ad inserter ad blocking detection

Ad blocking detection has some additional parameters that you may need.

Action here is a general action that is fired immediately (or after specified delay) when ad blocking is detected. Possible actions are None, Popup message and Page redirection.

When a user using ad blocker comes to your website you can delay action until few pages are visited. Delay action is the number of pages that the visitor must visit before the action triggers. Leave empty for immediate action.

When the action is triggered and the visitor, for example, closes the popup message, the action will not trigger again during the No Action Period. This is a period in days (saved in a cookie) when the user can browse the website without any warning or redirection. Leave empty to always trigger action every time the page is visited.

Delay action and No Action Period affect only actions set here. Ad replacement and content protection are not affected by these settings.

In order to improve or customize ad blocking detection Ad Inserter supports custom CSS selectors that are checked in order to detect ad blocking. This is an advanced feature and must be used with care – you need to know some HTML and CSS basics in order to use it. To get right CSS selector you can use web inspector in the browser or built-in HTML Element Selection tool. Click on the small button after the field to open HTML element selection window.

CSS selector can be any class name or id that can identify your ad that may be blocked. Blocking is detected by checking ad height. If it is 0 it means that ad blocking prevented the ad from showing. For example, you have the following ad:

<div id="header-ad">
  <a href=""><img src="" /></a>

To use this banner for ad blocking detection use #header-ad for custom CSS selector.

PRO Ad Inserter Pro has additional ad blocking detection algorithms. In case there are problems with ad blocking detection you can switch to Standard mode.

Popup Message

Popup message is a typical action when you want to inform visitor that ad blocking was detected and he needs to do something. Message is normally displayed over semi-transparent overlay which covers the page. You can configure the message text (including HTML), message CSS and overlay CSS. Click on the Preview button to open Popup editor.

ad inserter ad blocking message

Check Undismissible message to prevent the visitor from closing the popup window.

This is very annoying and should be used with care! You are preventing the user from visiting your website!

To test the message click on the Preview button. A preview window will open. Here you can change text and CSS and watch live preview of the message.

ad inserter ad blocking message preview

To undo changes click on the Reset button to revert back to the saved code. To get default settings for the message click on the Default button. Use + – buttons to increase or decrease the number of dummy paragraphs under message.

Once you are happy with the message click on Use to copy the settings to the Ad Inserter page. Click on Save settings to save them.


When ad blocking is detected you can redirect visitor to any existing static page or custom url. Custom url can be absolute or relative.

ad inserter ad blocking redirection

Popup message and redirection

In some cases you may want to show popup message with a link to some page explaining the problem. It is not enough to include a link to the page in the popup message because when the visitor will click on the link he will be redirected to that page but popup message will again appear. To prevent this put shortcode [adinserter adb="no-action"] into the page to prevent ad blocking actions on that page.

PRO Ad Replacement

In addition to popup messages and page redirection you can replace ads that were blocked with some that may not be blocked. You can also hide or show some ads (or whatever is in the code block) when ad blocking is detected. Each code block has a setting for this – button Misc / tab Ad Blocking.

Ad Blocking detection needs to be enabled for ad replacement to work (tab / tab Ad Blocking). You also can’t use No Wrapping style as wrapping div has to be used in order to mark code blocks which need to be replaced/shown/hidden.

Do nothing

ad inserter ad blocking block do nothing

This is the default setting for code block. When ad blocking is detected it does nothing.


ad inserter ad blocking block replace

When ad blocking is detected the code block will be replaced with replacement code block (ad). Replacing means that the replacement block is normally inserted but hidden (using CSS). When ad blocking is detected the original ad is hidden (regardless whether it was blocked or not) and the replacement ad is shown.

Choose replacement ads wisely. Do not name images with standard names (ad, ads, banner) or with ad dimensions (300×250). Use some neutral name that will not alert ad blockers.


The block is normally inserted but hidden (using CSS). When ad blocking is detected the ad (or any code) is shown.


The block is normally inserted and visible. When ad blocking is detected the ad (or any code) is hidden.

PRO Content protection

Ad Inserter Pro supports also few methods to protect content when ad blocking is detected. This way you can hide, delete or change (via Javascript and CSS) some parts of the content that you don’t want to show to visitors using ad blocking. Content protection works by inserting special shortcodes to mark content block that needs to be protected.

Normally you would need two code blocks: one to mark beginning and one to mark end of protected content. For example, if you would like to protect text in posts except the first and last paragraph you would insert shortcode to mark the beginning after the first paragraph and shortcode to mark the end before the last paragraph.

Use code block insertion options as for inserting any other code. The only difference is that you should use No Wrapping style so the codes are inserted without any wrapping div. You can also use only shortcode to mark the beginning of protected block as protection will work until the end of the parent container – inside posts this usually means until the end of the post. Of course, you don’t need to use automatic insertion. Once the code block is configured you can also manually insert shortcodes where needed.

Protection works by Javascript code which once ad blocking is detected, looks for HTML “markers” (generated by shortcodes) and then applying requested protection until the end marker is found or there are no more elements inside container (usually a div). This may sound complicated but it is easy to use and very powerful tool to protect content.

Hide Content

Hiding works by applying CSS display: none;. The content is still present on the page but it is not visible. Any advanced user could open web inspector in browser and change visibility back. However, for most visitors this will look like the content is missing or protected. Shortcodes:

[ADINSERTER adb='hide']

[ADINSERTER adb='hide-end']

Delete Content

To the visitor this looks the same as hiding. The difference is that here is the content actually deleted from the page DOM. Therefore, it is not possible to open web inspector in browser and get the content back. Shortcodes:

[ADINSERTER adb='delete']

[ADINSERTER adb='delete-end']

Change Style

You can also change the style of the protected content. The content is still present on the page but it is modified to decrease readability or to show it is protected. Shortcodes:

[ADINSERTER adb='css' css='ANY CSS CODE']

[ADINSERTER adb='css-end']

For example, to change the color of the protected text to some light gray you would use

[ADINSERTER adb='css' css='color: #ddd;']

Replace Text

You can also change the text of the protected content. The page still looks similarly as with the original text, however, when the visitor comes to the protected part he sees that there is something wrong. Ad Inserter will try to replace the original content with new text taking into account the length of the paragraph so the content layout will look like with the original text. Shortcodes:

[ADINSERTER adb='replace' text='ANY TEXT']

[ADINSERTER adb='replace-end']

Of course, you can use text replacement and style change. For example:

[ADINSERTER adb='css' css='color: #ddd;']

[ADINSERTER adb='replace' text='You are using ad blocker. ']

Content Selectors

To have more control over what is protected, Ad Inserter Pro supports to define comma separated list of CSS selectors in shortcodes. When no selector is specified a default selector p is used as most posts use <p> paragraphs. This is useful when your content that needs to be protected uses different elements (p, div, ul, ol, li, blockquote, figure, etc.). With selectors you can have a detailed control over what will be protected and how. For example, if posts have also <li> elements in lists <ul> you would use shortcode

[ADINSERTER adb='css' css='color: #ddd;' selectors='p, li']

Troubleshooting Content Protection

ad inserter ad blocking enabled

  1. Make sure ad blocking detection is enabled
  2. Make sure code blocks to mark protected block (where shortcodes are placed) have No Wrapping style
  3. Use debugging functions to simulate and test ad blocking

Debugging Ad Blocking Detection

Ad blocking detection works by checking if all scripts were properly loaded and no elements were blocked. For this to work properly Ad Inserter needs working Javascript with no errors and the scripts used by the plugin need to be present on the page exactly where they were inserted by the plugin. Some caching plugins may include those scripts as inline scripts and some plugins may “optimize” JavaScript code and consequently modify the order in which scripts used for ad blocking detection are loaded. In such case the plugin will assume ad blocking is present – false ad blocking detection. The easiest way to diagnose the problem is to disable caching and optimizing plugins that may change page source. Once ad blocking works properly enable plugins one by one to see which causes problems. Take into account also external caching and Javascript code optimizations with services like CloudFlare. 

If you see that ad blocking detection is triggered even when no ad blocker is active check the following:

  • There are no javascript errors on the page – check browser’s console for any messages or errors
  • All the scripts used by the plugin are present in the original order – check ad blocking detection with disabled caching and optimizing plugins. You may need to exclude those scripts from optimization:
<script type='text/javascript' src=''></script>
<script type='text/javascript' src=''></script>

In order to test ad blocking functions without actually using ad blocking software Ad Inserter supports two debugging functions available form the Ad Inserter menu item in the admin toolbar on the top of the pages – available when you are logged in, Toolbar is enabled for the user (WordPress menu Users / Your Profile), Debugging function in admin toolbar is enabled (tab / tab Debugging) and Ad Blocking Detection is enabled (tab / tab Ad Blocking).

ad inserter ad blocking debugging

Ad Blocking Status

When this function is enabled you will see a bar below the toolbar showing the status of ad blocking detection: whether ad blocking is detected, whether action was taken, whether action cookie is present and how many page views were already counted (if used).

ad inserter ad blocking debugging status

Simulate Ad Blocking

With this function you can simulate and test ad blocking detection without actual ad blocking software. Ad Inserter will behave as there is ad blocking present. Of course, no ads will be blocked, only plugin ad blocking functions will be triggered when the page is loaded.

Practical examples of content protection

Here we have a post with few paragraphs. When ad blocking is used we would like to protect all the paragraphs except the first three. For protection we will use shortcode to delete content. This is the original post:

ad inserter ad blocking example

Ad Inserter Pro settings for content protection code block:

  • Automatic insertion: Before paragraph
  • Paragraph number: 4
  • Alignment and Style: No Wrapping
  • Code: [ADINSERTER adb='delete']

ad inserter ad blocking example

We will not use shortcode to end protection as we are protecting until the end of the post. Now either activate ad blocking or use Simulate Ad Blocking debugging function and reload post. You should see only the first three paragraphs.

ad inserter ad blocking example

Example with changed font size and color

  • Automatic insertion: Before paragraph
  • Paragraph number: 4
  • Alignment and Style: No Wrapping
  • Code: [ADINSERTER adb='css' css='font-size: 11px; color: #ddd;']

The post when adblocking is active:

ad inserter ad blocking example


Example with replaced text

  • Automatic insertion: Before paragraph
  • Paragraph number: 4
  • Alignment and Style: No Wrapping
  • Code: [ADINSERTER adb='replace' text='You are using Ad Blocker. ']

The post when adblocking is active:

ad inserter ad blocking example

Example with ad blocking information and deleted text

This is probably the best approach for content protection as you are protecting the content and you are also informing the visitor why the content is missing.

One code block for the message:

  • Automatic insertion: After paragraph
  • Paragraph number: 3
  • When ad blocking is detected: Show
  • Code:
<hr />
<p><strong>Blocked because of Ad Blocker</strong></p>
<p>It seems that you are using some ad blocking software which is preventing the page from fully loading. Please whitelist this website or disable ad blocking software.</p>

One code block for content protection:

  • Automatic insertion: Before paragraph
  • Paragraph number: 4
  • Alignment and Style: No Wrapping
  • Code: [ADINSERTER adb='delete']

We can’t use one code block for the message and shortcode since the message needs wrapping div to show it only when ad blocking is detected. Settings for the second block assume you have configured Ad Inserter to not count paragraphs inside div (tab / tab General) as the block above will insert paragraphs with p tags.

The post when adblocking is active:

ad inserter ad blocking example