LOG IN SIGN UP
Documentation

GeoIP-related VCL features

Fastly exposes a number of geographic variables for you to take advantage of inside VCL. These are based on the MaxMind IP Geolocation database and appear as follows:

Variable Description
geoip.latitude The latitude associated with the IP address.
geoip.longitude The longitude associated with the IP address.
geoip.city The city or town name associated with the IP address. See MaxMind's list of cities for a list of all the possible return values. Their list is updated on a regular basis. The returned string uses the character encoding ISO-8859-1 (latin1).
geoip.city.latin1 An alias of geoip.city. The returned string uses the character encoding ISO-8859-1 (latin1).
geoip.city.utf8 The string from geoip.city encoded using the UTF-8 character encoding.
geoip.city.ascii The string from geoip.city encoded using the ASCII character encoding (an ASCII approximation of the original string with diacritics removed).
geoip.continent_code A two-character code representing the continent associated with the IP address. Possible codes are: AF - Africa, AS - Asia, EU - Europe, NA - North America, OC - Oceania, SA - South America.
geoip.country_code A two-character ISO 3166-1 country code for the country associated with the IP address. In addition to the standard codes, we may also return one of the following: A1 - an anonymous proxy, A2 - a satellite provider, EU - an IP in a block used by multiple European countries, AP - an IP in a block used by multiple Asia/Pacific region countries. Note: The US country code is returned for IP addresses associated with overseas US military bases.
geoip.country_code3 The same as country_code; however, it returns a ISO 3166-1 alpha-3 three-character code.
geoip.country_name The country name associated with the IP address. The returned string uses the character encoding ISO-8859-1 (latin1).
geoip.country_name.ascii The string from geoip.country_name encoded using the ASCII character encoding (an ASCII approximation of the original string with diacritics removed).
geoip.country_name.latin1 An alias of geoip.country_name. The returned string uses the character encoding ISO-8859-1 (latin1).
geoip.country_name.utf8 The string from geoip.country_name encoded using the UTF-8 character encoding.
geoip.postal_code The postal code associated with the IP address. These are available for some IP addresses in Australia, Canada, France, Germany, Italy, Spain, Switzerland, United Kingdom, and the US. We return the first 3 characters for Canadian postal codes. We return the first 2-4 characters (outward code) for postal codes in the United Kingdom.
geoip.region The region name associated with the IP address. See MaxMind's FAQ about converting region codes to names. The returned string uses the character encoding ISO-8859-1 (latin1).
geoip.region.latin1 An alias of geoip.region. The returned string uses the character encoding ISO-8859-1 (latin1).
geoip.region.utf8 The string from geoip.region encoded using the UTF-8 character encoding.
geoip.region.ascii The string from geoip.region encoded using the ASCII character encoding (an ASCII approximation of the original string with diacritics removed).
geoip.area_code The telephone area code associated with the IP address. These are only available for IP addresses in the US.
geoip.metro_code The metro code associated with the IP address. These are only available for IP addresses in the US.

Fastly also exposes codes that describe the location of the data center the request came through as follows:

Variable Description
server.region A code representing the general region of the world in which the POP location resides. One of: APAC, Asia, EU-Central, EU-East, EU-West, Middle-East, North-America, SA-East, South-America, US-Central, US-East, US-West.
server.datacenter A code representing one of Fastly's POP locations.