Get visitor location

Ecwid.getVisitorLocation(); provides information about customer's location. This information can be get via shipping or billing address (if the address is already filled or user is registered) or via IP address.

Get information about customer’s location:

Ecwid.getVisitorLocation();

// {countryCode: 'US', stateCode: 'NE', source: 'SHIPPING_ADDRESS'}

// {countryCode: 'RU', stateCode: '78', source: 'IP_ADDRESS'}

Fields

NameTypeDescription
countryCodestringCustomer’s country code (if no data found, returns ‘null‘)
stateCodestringCustomer’s state code (if no data found, returns ‘null‘)
sourcestringThe source of the received country code and state code. Possible values: 'SHIPPING_ADDRESS’, ‘BILLING_ADDRESS’, 'IP_ADDRESS’.

Subscribe to the Ecwid.OnAPILoaded JS API event to ensure availability of this function.