User Location Object
The userLocation
request object contains properties that specify the geographic location of a given request . The properties include city
,continent
, country
, region
, or zipCode
based on the IP address of the requesting device. For more information, see the EdgeScape documentation available in the Download Center.
city
Returns a userLocation
object that specifies the city name, within a 50-mile radius, of the incoming request. Refer to the Cities ZIP file ( 57MB uncompressed) for syntax. This is a read-only string value.
// Request originates in the city of Cambridge
request.userLocation.city;
// => "CAMBRIDGE"
continent
Returns a userLocation
object that specifies the two letter code for the continent of the incoming request. Refer to the Continent Code list for syntax. This is a read-only string value.
// Request originates in North America
request.userLocation.continent;
// => "NA"
country
Returns a userLocation
object that specifies the ISO-3166, two letter code for the country of the incoming request. Refer to the Country Code list for syntax. This is a read-only string value.
// Request originates in United States
request.userLocation.country;
// => "US"
region
Returns an ISO-3166, two-letter code for the state, province, or region of the incoming request. Refer to the State/Region Code list for syntax. This is a read-only string value.
// Request originates in the state of Massachusetts
request.userLocation.region;
// => "MA"
zipCode
Returns a userLocation
object that specifies the zip code of the incoming request. Multiple values are supported. Contiguous zip codes are represented as a range "FirstZipInRange-LastZipInRange". Multiple values are separated by the plus (+) character. For example, the following strings are all valid zipCode values:
-
10001
-
10001+10003
-
10001-10003+10005
-
10001-10003+10005-10008
For country = US and country = PR, zip refers to the five digit zip code. For
country = CA, zip refers to the Forward Sortation Area (FSA). For more information on
FSA, go to http://www.canadapost.ca and search for FSA. Refer to the Zip Code list for syntax. This is a read-only string value.
// Request originates in a Cambridge zipcode
request.userLocation.zipCode;
// => "02114+02134+02138-02142+02163+02238"
Updated about 1 month ago