DEAL ENDS IN:

SPRING SALE!

UP TO 35% OFF!

GET IT NOW

  • Home
  • Display the visitor’s country flag

How to display the visitor's country flag

If-So allows you to easily display the visitor’s county flag (image or emoji) using a simple DKI shortcode. The user location is detected based on the user IP.

To use the Flags DKI Shortcode, you need to install the If-So Geolocation extension, which is available for free.

Below is the shortcode that displays the flags above:

[ifsoDKI type='geo' show='flag' width='50px']

Flags DKI Shortcode and Page Caching Compatibility

The Flags DKI Shortcode is fully compatible with page caching, regardless of which caching plugin or solution you are using on your website.

If you are using page caching, you can ensure that the Flags DKI Shortcode is dynamically refreshed by adding the ‘ajax=’yes” parameter to the DKI shortcode. This parameter causes the shortcode to be rendered after the rest of the page is loaded from the cache, ensuring that the correct country flag is displayed to each visitor.

[ifsoDKI ajax='yes' type='geo' show='flag' width='200px']

Assigning a CSS class to the flag element

Optional: Include the ‘classname’ parameter to assign a CSS class to the flag element.

[ifsoDKI type='geo' show='flag' width='50px' classname='class-you-choose'] 

Displaying an Emoji of the Flag

To display an emoji of the visitor’s country flag, use the shortcode below:

Please note that this feature depends on the visitor’s browser being able to display flag emojis. While most modern browsers support flag emojis, some older browsers (such as desktop versions of Chrome) do not. In cases where flag emojis are not supported, the shortcode will display the country ISO code instead.

🇺🇸
[ifsoDKI type='geo' show='emoji-flag']

More about If-So’s geolocation service

  • Was this Helpful ?
  • YesNo
Ready to get started?
Try it on your website