# Class Geolocation

- [TopLevel.Object](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md)
  - [dw.util.Geolocation](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.util.Geolocation.md)

Read-only class representing a position on the earth (latitude and longitude)
and information associated with that location (e.g. country, city, etc). The
Commerce Cloud Digital system can provide geolocation information for a Request
and this information can be used in customer group segmentation rules.

Note: This class is not related to the store locator API (i.e. the
GetNearestStores pipelet) which uses a static set of store locations loaded
into the system by the merchant.

This product includes GeoLite2 data created by MaxMind, available from
<http://www.maxmind.com>.

## Property Summary

| Property                                                                                                                      | Description                                                                                                                                |
| ----------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
| [available](#available): [Boolean](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Boolean.md) `(read-only)`   | Returns 'true' if a valid GeoLocation was found for the IP address  (meaning at least Latitude and Longitude were found), false otherwise. |
| [city](#city): [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md) `(read-only)`               | Get the city name in English associated with this location.                                                                                |
| [countryCode](#countrycode): [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md) `(read-only)` | Get the ISO country code associated with this location.                                                                                    |
| [countryName](#countryname): [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md) `(read-only)` | Get the country name in English that the system associates with this location on the  earth.                                               |
| [latitude](#latitude): [Number](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Number.md) `(read-only)`       | Get the latitude coordinate associated with this location which is a  number between -90.0 and +90.0.                                      |
| [longitude](#longitude): [Number](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Number.md) `(read-only)`     | Get the longitude coordinate associated with this location which is a  number between -180.0 and +180.0.                                   |
| [metroCode](#metrocode): [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md) `(read-only)`     | Get the metro code associated with this location.                                                                                          |
| [postalCode](#postalcode): [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md) `(read-only)`   | Get the postal code associated with this location.                                                                                         |
| [regionCode](#regioncode): [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md) `(read-only)`   | Get the region (e.g.                                                                                                                       |
| [regionName](#regionname): [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md) `(read-only)`   | Get the region (e.g.                                                                                                                       |

## Constructor Summary

| Constructor                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   | Description                          |
| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------ |
| [Geolocation](#geolocationstring-string-string-string-string-string-string-number-number)([String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md), [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md), [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md), [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md), [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md), [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md), [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md), [Number](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Number.md), [Number](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Number.md)) | Constructor for a Geolocation object |

## Method Summary

| Method                                                                                                          | Description                                                                                                                                |
| --------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
| [getCity](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.util.Geolocation.md#getcity)()               | Get the city name in English associated with this location.                                                                                |
| [getCountryCode](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.util.Geolocation.md#getcountrycode)() | Get the ISO country code associated with this location.                                                                                    |
| [getCountryName](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.util.Geolocation.md#getcountryname)() | Get the country name in English that the system associates with this location on the  earth.                                               |
| [getLatitude](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.util.Geolocation.md#getlatitude)()       | Get the latitude coordinate associated with this location which is a  number between -90.0 and +90.0.                                      |
| [getLongitude](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.util.Geolocation.md#getlongitude)()     | Get the longitude coordinate associated with this location which is a  number between -180.0 and +180.0.                                   |
| [getMetroCode](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.util.Geolocation.md#getmetrocode)()     | Get the metro code associated with this location.                                                                                          |
| [getPostalCode](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.util.Geolocation.md#getpostalcode)()   | Get the postal code associated with this location.                                                                                         |
| [getRegionCode](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.util.Geolocation.md#getregioncode)()   | Get the region (e.g.                                                                                                                       |
| [getRegionName](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.util.Geolocation.md#getregionname)()   | Get the region (e.g.                                                                                                                       |
| [isAvailable](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.util.Geolocation.md#isavailable)()       | Returns 'true' if a valid GeoLocation was found for the IP address  (meaning at least Latitude and Longitude were found), false otherwise. |

### Methods inherited from class Object

[assign](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#assignobject-object), [create](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#createobject), [create](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#createobject-object), [defineProperties](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#definepropertiesobject-object), [defineProperty](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#definepropertyobject-object-object), [entries](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#entriesobject), [freeze](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#freezeobject), [fromEntries](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#fromentriesiterable), [getOwnPropertyDescriptor](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#getownpropertydescriptorobject-object), [getOwnPropertyNames](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#getownpropertynamesobject), [getOwnPropertySymbols](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#getownpropertysymbolsobject), [getPrototypeOf](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#getprototypeofobject), [hasOwnProperty](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#hasownpropertystring), [is](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#isobject-object), [isExtensible](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#isextensibleobject), [isFrozen](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#isfrozenobject), [isPrototypeOf](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#isprototypeofobject), [isSealed](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#issealedobject), [keys](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#keysobject), [preventExtensions](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#preventextensionsobject), [propertyIsEnumerable](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#propertyisenumerablestring), [seal](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#sealobject), [setPrototypeOf](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#setprototypeofobject-object), [toLocaleString](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#tolocalestring), [toString](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#tostring), [valueOf](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#valueof), [values](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#valuesobject)

## Property Details

### available

- available: [Boolean](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Boolean.md) `(read-only)`
  - : Returns 'true' if a valid GeoLocation was found for the IP address
    (meaning at least Latitude and Longitude were found), false otherwise.

***

### city

- city: [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md) `(read-only)`
  - : Get the city name in English associated with this location.

***

### countryCode

- countryCode: [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md) `(read-only)`
  - : Get the ISO country code associated with this location.

***

### countryName

- countryName: [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md) `(read-only)`
  - : Get the country name in English that the system associates with this location on the
    earth.

***

### latitude

- latitude: [Number](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Number.md) `(read-only)`
  - : Get the latitude coordinate associated with this location which is a
    number between -90.0 and +90.0.

***

### longitude

- longitude: [Number](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Number.md) `(read-only)`
  - : Get the longitude coordinate associated with this location which is a
    number between -180.0 and +180.0.

***

### metroCode

- metroCode: [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md) `(read-only)`
  - : Get the metro code associated with this location.

***

### postalCode

- postalCode: [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md) `(read-only)`
  - : Get the postal code associated with this location.

***

### regionCode

- regionCode: [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md) `(read-only)`
  - : Get the region (e.g. province or state) code for this location.

***

### regionName

- regionName: [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md) `(read-only)`
  - : Get the region (e.g. province in state) name in English that the system
    associates with this location.

***

## Constructor Details

### Geolocation(String, String, String, String, String, String, String, Number, Number)

- Geolocation(countryCode: [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md), countryName: [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md), regionCode: [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md), regionName: [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md), metroCode: [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md), city: [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md), postalCode: [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md), latitude: [Number](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Number.md), longitude: [Number](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Number.md))
  - : Constructor for a Geolocation object

    **Parameters:**

    - countryCode - the ISO country code associated with this location.  The [two-character ISO          3166-1 alpha code](http://en.wikipedia.org/wiki/ISO\_3166-1) for the country.
    - countryName - the country name in English that the system associates with this location on the  earth.
    - regionCode - the region (e.g. province or state) code for this location.  This is a string up to three characters long containing the subdivision portion of the  [code](http://en.wikipedia.org/wiki/ISO\_3166-2).
    - regionName - the region (e.g. province in state) name in English that the system  associates with this location.
    - metroCode - the metro code associated with this location.  The metro code of the location if the location is in the US. See the  [  Google AdWords API](https://developers.google.com/adwords/api/docs/appendix/cities-DMAregions) for values
    - city - the city name in English associated with this location.
    - postalCode - the postal code associated with this location.
    - latitude - the latitude coordinate associated with this location which is a  number between -90.0 and +90.0.
    - longitude - the longitude coordinate associated with this location which is a  number between -180.0 and +180.0.

***

## Method Details

### getCity()

- getCity(): [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md)
  - : Get the city name in English associated with this location.

    **Returns:**

    - the city that the system associates with this location on the
      earth.

***

### getCountryCode()

- getCountryCode(): [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md)
  - : Get the ISO country code associated with this location.

    **Returns:**

    - The [two-character ISO
      3166-1 alpha code](http://en.wikipedia.org/wiki/ISO\_3166-1) for the country.

***

### getCountryName()

- getCountryName(): [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md)
  - : Get the country name in English that the system associates with this location on the
    earth.

    **Returns:**

    - the country name that the system associates with this location on the
      earth.

***

### getLatitude()

- getLatitude(): [Number](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Number.md)
  - : Get the latitude coordinate associated with this location which is a
    number between -90.0 and +90.0.

    **Returns:**

    - The latitude of the location as a floating point number.

***

### getLongitude()

- getLongitude(): [Number](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Number.md)
  - : Get the longitude coordinate associated with this location which is a
    number between -180.0 and +180.0.

    **Returns:**

    - The longitude of the location as a floating point number.

***

### getMetroCode()

- getMetroCode(): [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md)
  - : Get the metro code associated with this location.

    **Returns:**

    - The metro code of the location if the location is in the US. See
      the [Google AdWords API](https://developers.google.com/adwords/api/docs/appendix/cities-DMAregions) for returned values.

***

### getPostalCode()

- getPostalCode(): [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md)
  - : Get the postal code associated with this location.

    **Returns:**

    - The postal code of the location. Postal codes are not available
      for all countries. In some countries, this will only contain part
      of the postal code.

***

### getRegionCode()

- getRegionCode(): [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md)
  - : Get the region (e.g. province or state) code for this location.

    **Returns:**

    - This is a string up to three characters long containing the
      subdivision portion of the [code](http://en.wikipedia.org/wiki/ISO\_3166-2).

***

### getRegionName()

- getRegionName(): [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md)
  - : Get the region (e.g. province in state) name in English that the system
    associates with this location.

    **Returns:**

    - the region name that the system associates with this location on
      the earth.

***

### isAvailable()

- isAvailable(): [Boolean](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Boolean.md)
  - : Returns 'true' if a valid GeoLocation was found for the IP address
    (meaning at least Latitude and Longitude were found), false otherwise.

    **Returns:**

    - 'true' if a valid GeoLocation was found for the IP address
      (meaning at least Latitude and Longitude were found), false otherwise.

***
