# 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:

```javascript
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 | <p>The source of the received country code and state code. </p><p></p><p>One of: </p><p><code>SHIPPING\_ADDRESS</code></p><p><code>BILLING\_ADDRESS</code></p><p><code>IP\_ADDRESS</code></p> |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.ecwid.com/storefronts/get-storefront-details/get-visitor-location.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
