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:


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

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


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.