Portal Engine Questions on portal engine and web parts.
Version 7.x > Portal Engine > different background image depending on the country of the user View modes: 
User avatar
Member
Member
rafik - 10/23/2013 1:59:27 PM
   
different background image depending on the country of the user
Hi guys.

I am trying to use the macro for when user visit the website, the background image change depending on the user country. But I dont find anything in macro about detecting the country by the ip.

Is someone has an idea

small exemple to understand my question:

User from USA:
Background image : USAImage.png

User from Korea:
Background image: KoreanImage.png

User avatar
Kentico Consulting
Kentico Consulting
Kentico_RichardS - 10/24/2013 3:15:19 AM
   
RE:different background image depending on the country of the user
Hi,

Thank you for your message.

In order to accomplish this you need to create a custom macro as per: http://devnet.kentico.com/docs/devguide/types_of_macros.htm?zoom_highlightsub=types%2Bof%2Bmacros

Then in macro you can get the geolocation object of the current user with:

CMS.WebAnalytics.GeoLocation myLocation = CMS.WebAnalytics.GeoIPHelper.GetCurrentGeoLocation();
string myCountry = myLocation.CountryName.ToString();


And then you can work with that and return whatever result you need.

Kind regards,
Richard Sustek