- Must be knowledgeable about setting up cookies on web servers.
Cloudflare has a network configuration called IP Geolocation. This feature includes the country code associated with your website’s visitor location when answering all requests on your website.
Using this information, we can set the widget to be displayed based on the visitor’s current location.
Setting up the “country” cookie
For this to work, you’ll need first to enable the IP Geolocation configuration. Learn how in the Configuring IP Geolocation section of this article: Configuring Cloudflare IP Geolocation
Next, you should now be able to receive the country code on your request headers.
Learn how to get the country code based on your preferred programming language in the Capturing Geolocation data in application logic section of Configuring Cloudflare IP Geolocation.
Once that’s done, you just need to set it as a cookie called “country” and we’ll be able to create criteria on which widget to display based on that cookie data.