Geotracking

Salesforce B2C Commerce supports geotracking through the IP address customer lookup 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, it returns null. If the IP address can't be found in the database, for example, the method returns null.

The geolocation feature is turned on by default, but Commerce Cloud Support can disable the feature per customer request.

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. The site selector page 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 that 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. Present 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.