Geotracking

Salesforce B2C Commerce supports geotracking through the IP address customer look up feature. You can use the dw.util.Geolocation class and dw.system.Request.getGeolocation() method to populate the pdict.CurrentRequest.httpRemoteAddress, then take action based on the associated country.
Note:

If the dw.system.Request.getGeolocation() method can't return a geolocation for whatever reason, it returns null. It will return null, for example, if the IP address can't be found in the database.

The geolocation feature is turned on by default, but can be disabled by turned on by default, but can be disabled by Commerce Cloud Support per customer request. If the method always returns null.

If the IP address is associated with a country you support with one of your sites, redirect to that site. If the IP address is associated with a country you do not support with one of your sites, you can direct to a "site selector" page that lets the visitor select a specific site by region. If you let a visitor explicitly select a site, consider also offering the option of saving a cookie to remember the selection for subsequent sessions.

On subsequent visits, if a cookie on the browser's computer indicates the customer has previously selected a preferred site, your app can redirect to that site regardless of the IP address. If you provide cookie-based site preference, it's important to let the visitor change that preference by presenting a link to the site selector page in the global user interface of the site. Geotracking can be used to delegate users from specific countries to country-specific landing pages.

Alternatively, check our LINK partners for pre-built integrations with geotracking functionality.