---
title: Geolocation
summary: null
url: https://www.fastly.com/documentation/reference/vcl/variables/geolocation
---

Fastly provides a variety of geolocation data, allowing the originating geographical location of a request to be determined.

> **IMPORTANT:** IP geolocation information, including data streamed by our [log streaming service](https://www.fastly.com/documentation/guides/integrations/logging), is intended to be used only in connection with your Fastly services. Use of geolocation data for other purposes may require permission from [Digital Element](https://www.digitalelement.com/), our data supplier.  For more information see our [overview of using IP-based geolocation and intelligence](https://www.fastly.com/documentation/guides/concepts/geolocation).

The `client.geo.` namespace contains the geolocation data we recommend for most use cases.  The `client.as.` namespace offers information about the client's [Autonomous System](https://en.wikipedia.org/wiki/Autonomous_system_(Internet)) (AS), which is often the end user's Internet Service Provider.

> **NOTE (Legacy geolocation dataset):** Fastly previously supported a legacy geolocation dataset for VCL with variables in the `geoip.` namespace. This dataset was provided by a third-party that has deprecated support for the dataset.
>
> As of May 27, 2022, these variables are no longer supported by Fastly. Attempting to activate a service containing these variables will fail. In general, variables in this legacy dataset are directly mappable to currently supported variables with the same name in the `client.geo.` namespace, but the values returned may not be exactly the same for a given IP address.
>
> The following suffixes for `geoip.` also exist in the `client.geo.` namespace:
>
> - `area_code`
> - `city`
> - `continent_code`
> - `country_code`
> - `country_code3`
> - `country_name`
> - `ip_override`
> - `latitude`
> - `longitude`
> - `metro_code`
> - `postal_code`
> - `region`
>
> In particular, keep in mind the following:
>
> - The legacy geolocation dataset did not support IPv6 addresses, while the new `client.geo.` dataset does.
> - The `geoip.use_x_forwarded_for` variable has no successor, but its behavior can be replicated by setting `client.geo.ip_override`.
> - The `city`, `country_name` and `region` variables have `.ascii`, `.latin1` and `.utf8` variants that also exist in both datasets.
> - The geolocation dataset versions each have different formatting conventions. For example, `client.geo.city` and `client.geo.country_name` exist as lowercase ASCII values whereas the values returned for the same fields in the `geoip.` namespace are mixed case.
> - The `client.geo.region` field contains [ISO 3166-2](https://en.wikipedia.org/wiki/ISO_3166-2) region codes but the `geoip.region` field contains [FIPS10-4](https://en.wikipedia.org/wiki/FIPS_10-4) region codes. The FIPS 10-4 standard was withdrawn in 2014.

## IP address used for lookup

The IP address used for the geolocation lookup is automatically populated from `client.ip` by default, but may be overridden explicitly by setting `client.geo.ip_override`.

## Lossy formats

Geographic variables representing names are available in several formats. Note in particular the `*.ascii` variables are lossy. These variables have diacritics removed and are normalized to lower case spellings. These `*.ascii` variables are intended for ease of use as a symbolic string in code (for example, to perform some different action depending on the city name), and are generally inappropriate for presenting to users due to their simplified content.

## Absent data

The data is updated periodically, as IP allocations change and various amendments are made. Some variables may be absent for the current data at any given time.

For STRING types, the special value `?` is used to indicate absent data. These may be normalized to VCL empty strings using the `if()` ternary operator:

```vcl
if (client.as.name == "?", client.as.name, "");
```

In general values of type `STRING` in VCL may be _not set_, but this should never occur for the Geolocation variables.

- [client.geo.area_code](https://www.fastly.com/documentation/reference/vcl/variables/geolocation/client-geo-area-code/)
- [client.geo.city](https://www.fastly.com/documentation/reference/vcl/variables/geolocation/client-geo-city/)
- [client.geo.city.ascii](https://www.fastly.com/documentation/reference/vcl/variables/geolocation/client-geo-city-ascii/)
- [client.geo.city.latin1](https://www.fastly.com/documentation/reference/vcl/variables/geolocation/client-geo-city-latin1/)
- [client.geo.city.utf8](https://www.fastly.com/documentation/reference/vcl/variables/geolocation/client-geo-city-utf8/)
- [client.geo.conn_speed](https://www.fastly.com/documentation/reference/vcl/variables/geolocation/client-geo-conn-speed/)
- [client.geo.conn_type](https://www.fastly.com/documentation/reference/vcl/variables/geolocation/client-geo-conn-type/)
- [client.geo.continent_code](https://www.fastly.com/documentation/reference/vcl/variables/geolocation/client-geo-continent-code/)
- [client.geo.country_code](https://www.fastly.com/documentation/reference/vcl/variables/geolocation/client-geo-country-code/)
- [client.geo.country_code3](https://www.fastly.com/documentation/reference/vcl/variables/geolocation/client-geo-country-code3/)
- [client.geo.country_name](https://www.fastly.com/documentation/reference/vcl/variables/geolocation/client-geo-country-name/)
- [client.geo.country_name.ascii](https://www.fastly.com/documentation/reference/vcl/variables/geolocation/client-geo-country-name-ascii/)
- [client.geo.country_name.latin1](https://www.fastly.com/documentation/reference/vcl/variables/geolocation/client-geo-country-name-latin1/)
- [client.geo.country_name.utf8](https://www.fastly.com/documentation/reference/vcl/variables/geolocation/client-geo-country-name-utf8/)
- [client.geo.gmt_offset](https://www.fastly.com/documentation/reference/vcl/variables/geolocation/client-geo-gmt-offset/)
- [client.geo.ip_override](https://www.fastly.com/documentation/reference/vcl/variables/geolocation/client-geo-ip-override/)
- [client.geo.latitude](https://www.fastly.com/documentation/reference/vcl/variables/geolocation/client-geo-latitude/)
- [client.geo.longitude](https://www.fastly.com/documentation/reference/vcl/variables/geolocation/client-geo-longitude/)
- [client.geo.metro_code](https://www.fastly.com/documentation/reference/vcl/variables/geolocation/client-geo-metro-code/)
- [client.geo.postal_code](https://www.fastly.com/documentation/reference/vcl/variables/geolocation/client-geo-postal-code/)
- [client.geo.proxy_description](https://www.fastly.com/documentation/reference/vcl/variables/geolocation/client-geo-proxy-description/)
- [client.geo.proxy_type](https://www.fastly.com/documentation/reference/vcl/variables/geolocation/client-geo-proxy-type/)
- [client.geo.region](https://www.fastly.com/documentation/reference/vcl/variables/geolocation/client-geo-region/)
- [client.geo.region.ascii](https://www.fastly.com/documentation/reference/vcl/variables/geolocation/client-geo-region-ascii/)
- [client.geo.region.latin1](https://www.fastly.com/documentation/reference/vcl/variables/geolocation/client-geo-region-latin1/)
- [client.geo.region.utf8](https://www.fastly.com/documentation/reference/vcl/variables/geolocation/client-geo-region-utf8/)
- [client.geo.utc_offset](https://www.fastly.com/documentation/reference/vcl/variables/geolocation/client-geo-utc-offset/)
