Before you start, a few important notes:

  • This script is based on the detection of your visitor’s IP. If your colleagues don’t share the same IP or are not in the same IP range, this option won’t work.
  • This script will slow down the display of your popups because we check your visitors’ IP before displaying the popups. It won’t slow down your website.
  • This script is useful if you cannot write back-end code. If you can, try to retrieve the visitor IP from the request that hit your server and set it as a Wisepops’ custom property.

Step 1:

Copy and paste the following script:

<script type="text/javascript" data-cfasync="false">
    (function () {
        function initWisePops() {
            /**
             * WisePops tracking code goes here
             */
            (function(W,i,s,e,P,o,p){W['WisePopsObject']=P;W[P]=W[P]||function(){
                (W[P].q=W[P].q||[]).push(arguments)},W[P].l=1*new Date();o=i.createElement(s),
                p=i.getElementsByTagName(s)[0];o.async=1;o.src=e;p.parentNode.insertBefore(o,p)
            })(window,document,'script','//loader.wisepops.com/get-loader.js?v=1&site=qHVNGSazwg','wisepops');

        // Fetch IP only once per browser session
        if (XMLHttpRequest && sessionStorage && !sessionStorage.getItem('wisepops_ip')) {
            var xhr = new window.XMLHttpRequest();
            xhr.onload = function () {
                // Init WisePops only once we know the IP
                initWisePops();
                if (this.status === 200) {
                    sessionStorage.setItem('wisepops_ip', 'ok');
                    // Set the IP as WisePops custom property
                    wisepops('properties', {
                        ipAddress: JSON.parse(this.responseText).ip
                    });
                }
            };
            xhr.onerror = function () {
                initWisePops();
                console.error(this.responseText);
            };
            xhr.open('GET', 'https://api.ipify.org?format=json', true);
            xhr.send(null);
        } else {
            initWisePops();
        }
    })();

 
</script>


Note: if you have existing custom properties, you can use this script instead and place your custom properties below this comment:

            /**
             * We can set additional custom properties here
             */

<script type="text/javascript" data-cfasync="false">
    (function () {
        function initWisePops() {
            /**
             * WisePops tracking code goes here
             */
            (function(W,i,s,e,P,o,p){W['WisePopsObject']=P;W[P]=W[P]||function(){
                (W[P].q=W[P].q||[]).push(arguments)},W[P].l=1*new Date();o=i.createElement(s),
                p=i.getElementsByTagName(s)[0];o.async=1;o.src=e;p.parentNode.insertBefore(o,p)
            })(window,document,'script','//loader.wisepops.com/get-loader.js?v=1&site=qHVNGSazwg','wisepops');

            /**
             * We can set additional custom properties here
             */
            wisepops('properties', {
                hello: 'world'
            });
        }

        // Fetch IP only once per browser session
        if (XMLHttpRequest && sessionStorage && !sessionStorage.getItem('wisepops_ip')) {
            var xhr = new window.XMLHttpRequest();
            xhr.onload = function () {
                // Init WisePops only once we know the IP
                initWisePops();
                if (this.status === 200) {
                    sessionStorage.setItem('wisepops_ip', 'ok');
                    // Set the IP as WisePops custom property
                    wisepops('properties', {
                        ipAddress: JSON.parse(this.responseText).ip
                    });
                }
            };
            xhr.onerror = function () {
                initWisePops();
                console.error(this.responseText);
            };
            xhr.open('GET', 'https://api.ipify.org?format=json', true);
            xhr.send(null);
        } else {
            initWisePops();
        }
    })();

Step 2:

Replace the tracking code with your own Wisepops’ tracking code:

Step 3:

In all your popup campaigns, create a rule using the property we just created: ipAddress.

From there, you can create “does not contain” rules based on the first 3 sets of numbers of the IP address if you want to exclude a range or “is not equal to” if you want to exclude a specific IP address.

Did this answer your question?