Geo
The context object in a request describes the location and visitor requesting data. The values in the object are used to select which rules are applied during search.
You have to use the locale object to set the geo property of the context for a request included in Sitecore Search JS SDK for React or JS Data package. The locale is represented by two-letter codes for country and language.
|
Property |
Type |
Description |
|---|---|---|
|
|
string |
IP address of the browser or native application of the system the visitor is on. Don't pass the IP address of your proxy. If you don't pass |
|
|
GeoLocation |
Object describing a location with |
GeoLocation
|
Property |
Type |
Description |
|---|---|---|
|
|
number |
The latitude of the visitor in decimal degrees (DD) format. Don't use spaces. For example, pass |
|
|
number |
The longitude of the visitor in decimal degrees (DD) format. Don't use spaces. For example, pass |
Set or update context geo
We recommend you set the geo-location in your first search or recommendation request. The SDK stores this value and sets it in future requests. In a very unlikely situation, if the geo-location changes during a visit, you must update the geo-location for accurate reporting.
To set the locale in context for a search request:
-
Use the following code block, adding or replacing your own values:
RequestResponsequery: (query:SearchResultsWidgetQuery) => query.getRequest().setContextGeo({ location: { "41.40338", "2.17403" } })
To update the locale in context for a search request:
-
Use the following code block, adding or replacing your own values:
RequestResponsequery: (query:SearchResultsWidgetQuery) => query.getRequest().updateContextGeo({ ip:"192.0.2.1"})