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
Name | Type | Description |
---|---|---|
countryCode | string | Customer’s country code (if no data found, returns ‘null‘) |
stateCode | string | Customer’s state code (if no data found, returns ‘null‘) |
source | string | The 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.