Disable Rules
Disable Rules allow you to prevent htag from loading ads on specific pages or sections of your website. This is useful for pages where you don’t want to show ads, such as login pages, error pages, or premium content.
How It Works
Section titled “How It Works”Disable Rules are regular expressions that are matched against the current URL. If a match is found, htag will not load any ads on that page. The rules are evaluated both for the canonical URL (if available) and the current URL.
Configuration
Section titled “Configuration”Disable Rules are typically configured through the Adconsole interface, but they can also be added programmatically through the API.
Custom Disable Logic
Section titled “Custom Disable Logic”In addition to URL-based disable rules, htag also supports custom disable logic through the window.htag.isDisabled function. This function should return a Promise that resolves to a boolean value indicating whether ads should be disabled.
Example
Section titled “Example”Here’s an example of how to implement custom disable logic:
window.htag = window.htag || {};window.htag.isDisabled = async function () { // Disable ads for premium users return isPremiumUser();};When Disable Rules Are Checked
Section titled “When Disable Rules Are Checked”Disable Rules are checked at the following times:
- When htag is initialized
- When ads are refreshed
Related Concepts
Section titled “Related Concepts”- Placements: Learn about ad placement configuration
- Refresh Ads: Learn about refreshing ads