by Overwolf
  • Nitro
  • Publishers
    PUBLISHERS
    How it Works Documentation Newsletter
  • Advertisers
    ADVERTISERS
    Advertisers Offering Top Sites
  • Resources
    RESOURCES
    Ad Unit Demos Blog & News Press Releases FAQ Case Studies
  • NitroDex
Log in

Ad Publishers

  • Helpful Integration Tools and Common Issues
  • Google MCM – What is it?
  • Installing the ad script on your page
  • Setting up your ads.txt file
  • Creating an ad placement
  • Special Ad Formats
  • Detecting ad-blocking users
  • Creating a Playlist and Adding Content

Data and Privacy

  • Passing Hashed Emails
  • Creating a link for the user to manage their consents
  • US Privacy law compliance steps
  • Support for Google Analytics and Consent Mode
  • Adding custom consents or disclosures

Dashboard and Best Practices

  • Ad Layout Best Practices
  • Nitro Glossary
  • NitroPay
  • Docs
  • Ad Publishers
  • Detecting ad-blocking users

Detecting ad-blocking users

This code lets you detect with a high degree of reliability if a user is blocking NitroPay’s ad script.

Embed the following script anywhere on your page

<script type="text/javascript">
var npDetect = new (function () {
    this.blocking = false;
    var errcnt = 0;
    function testImg() {
        var i = new Image();
        i.onerror = () => {
            errcnt++;
            if (errcnt < 3) {
                setTimeout(testImg, 250);
            } else {
                npDetect.blocking = true;

                if (document.dispatchEvent && window.CustomEvent) {
                    document.dispatchEvent(
                        new CustomEvent('np.blocking', {
                            detail: {
                                blocking: npDetect.blocking,
                            },
                        })
                    );
                }
            }
        };
        i.onload = () => {
            npDetect.blocking = false;
        };

        i.src = 'https://s.nitropay.com/1.gif?' + Math.random() + '&adslot=';
    }
    testImg();
})();
</script>

Embed this script to listen for the np.blocking event. You should perform whatever task is necessary such as re-adjusting your layout or displaying an appeal to the user if this event is fired.

<script type="text/javascript">
document.addEventListener('np.blocking', (e) => {
    if (e.detail.blocking) {
        // the user is blocking the nitropay script
    }
});
</script>
What are your Feelings
Share This Article :
  • Facebook
  • Twitter
  • LinkedIn
  • Pinterest
Updated on January 25, 2023
Special Ad FormatsCreating a Playlist and Adding Content
We use cookies to improve your experience and increase the relevancy of content when using Nitro. Our cookies are used for analytics, optimization, and advertising operations. Learn more.Got it
  • Publishers

    • How it works
    • Documentation
    • Newsletter
  • Advertisers

    • Advertisers Offering
    • Top Sites
  • Resources

    • Ad Unit Demos
    • Blog & News
    • Press Releases
    • FAQ
    • Case Studies
  • Companions

    • Overwolf
    • CurseForge
    • Tebex
  • Nitrodex

© Overwolf. All rights reserved.
  • Terms of Service
  • Privacy Policy