Get visitor location

Ecwid.getVisitorLocation()

This method gets the visitor's location based on their shipping or billing address (when entered), or IP. The call works even for signed-out customers.

Request example:

console.log(
    JSON.stringify(
        Ecwid.getVisitorLocation()
    )
);

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

Fields available in the response:

Name
Type
Description

countryCode

string

Country code (null if not found) in ISO 639-1.

stateCode

string

State code (null if not found) in ISO 639-1.

source

string

The source of the received country code and state code.

One of:

SHIPPING_ADDRESS

BILLING_ADDRESS

IP_ADDRESS

Last updated

Was this helpful?