WordPress Popup Maker – GeoLocation

Hi, I’m relatively new to Reddit and WordPress. Apologies if this is the wrong place and/or if my wording/terminology is incorrect.

I’m looking to create a popup that is specific to one country. We have visitors from New Zealand and I’d like to have a popup on the HomePage that only opens when they visit from that country.

I have created a simple/test popup and this appears to work, but it’s basically on or it’s not.

I’m using Popup Maker and have inputted the following information at the end of the HTML code in the Edit Popup section.

<!– JavaScript code to detect user’s country and toggle content accordingly –>


function getCountry(callback) {

var xhr = new XMLHttpRequest();

[xhr.open](https://xhr.open)(‘GET’, ‘[https://ipinfo.io](https://ipinfo.io)’, true);

xhr.onload = function () {

if (xhr.status === 200) {

var response = JSON.parse(xhr.responseText);







function toggleContentByCountry(countryCode) {

var allowedCountries = \[‘NZ’\]; // Replace with the desired country code(s)

var contentDiv = document.getElementById(‘country-specific-content’);


if (allowedCountries.includes(countryCode)) {

contentDiv.style.display = ‘block’; // Show the content

} else {

contentDiv.style.display = ‘none’; // Hide the content




getCountry(function(country) {




**Please help!**



This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer