LOG IN SIGN UP
Documentation

Geolocation-related VCL features

  Last updated May 03, 2018

Fastly exposes a number of geographic variables for you to take advantage of inside VCL for both IPv4 and IPv6 client IPs. These variables appear as follows:

Variable Location Description
client.geo.latitude all The latitude associated with the IP address.
client.geo.longitude all The longitude associated with the IP address.
client.geo.city all The city or town name associated with the IP address, encoded using the ASCII character encoding (a lowercase ASCII approximation of the original string with diacritics removed).
client.geo.city.ascii all An alias of client.geo.city.
client.geo.city.utf8 all The city or town name associated with the IP address, encoded using the UTF-8 character encoding.
client.geo.continent_code all 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, AN - Antarctica.
client.geo.country_code all A two-character ISO 3166-1 country code for the country associated with the IP address. The US country code is returned for IP addresses associated with overseas United States military bases.
client.geo.country_code3 all A three-character ISO 3166-1 alpha-3 country code for the country associated with the IP address. The USA country code is returned for IP addresses associated with overseas United States military bases.
client.geo.country_name all The country name associated with the IP address, encoded using the ASCII character encoding (a lowercase ASCII approximation of the original string with diacritics removed).
client.geo.country_name.ascii all An alias of client.geo.country_name.
client.geo.country_name.utf8 all The country name associated with the IP address, encoded using the UTF-8 character encoding.
client.geo.postal_code all The postal code associated with the IP address. These are available for some IP addresses in Australia, Canada, France, Germany, Italy, Spain, Switzerland, the United Kingdom, and the United States. 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.
client.geo.region all The ISO 3166-2 region code associated with the IP address.
client.geo.area_code all The telephone area code associated with the IP address. These are only available for IP addresses in the United States.
client.geo.metro_code all The metro code associated with the IP address. Metro codes represent designated market areas (DMAs) in the United States and Germany, Independent Television Service (ITV) regions in the UK, department codes in France, South Korean administrative divisions (si, gun, gu or cities, counties, and districts), Chinese administrative regions (diji shi, or "region-level" cities), Russian federal districts, Norwegian municipalities, urban areas in New Zealand, and the Greater Capital City Statistical Area (GCCSA) and Significant Urban Areas (SUAs) in Australia.
client.geo.gmt_offset all The time zone offset from coordinated universal time (UTC) for the client.geo.city associated with the IP address.
client.geo.conn_speed all The type of connection speed associated with the IP address. Possible values are: broadband, cable, dialup, mobile, oc12, oc3, t1, t3, satellite, wireless, xdsl.
client.as.number all The autonomous system (AS) number associated with this IP address.
client.as.name all The name of the organization associated with client.as.number.

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

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

Using geographic variables with shielding

If you have shielding enabled, you should set the following variable before using geographic variables:

set client.geo.ip_override = req.http.Fastly-Client-IP;


Additional resources:


Back to Top