> ## Documentation Index
> Fetch the complete documentation index at: https://radarlabs-rob-onesignal-api-migration.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Localizing a website based on current country or city

In this tutorial, we show you how to use the Radar [web SDK](/sdk/web) and [IP geocoding API](/api#ip-geocode) to localize a website based on current country or city.

For example, you may show a default language or currency based on current country. Or, you may show nearby content based on current city.

## Video

<iframe className="youtube-clip" src="https://www.youtube.com/embed/yIjPk4nddBA?si=F6u4tYiv1Zr-_ASi" title="Youtube video player" frameBorder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowFullScreen />

## Languages used

* HTML
* JavaScript

## Features used

* [Web SDK](/sdk/web)
* [IP geocoding API](/api#ip-geocode)

## Steps

<Steps>
  <Step title="Sign up for Radar">
    If you haven't already, sign up for Radar to get your API key. You can make up to 100,000 API requests per month for free.

    [**Get API keys**](https://radar.com/signup)
  </Step>

  <Step title="Install the Radar web SDK">
    In an HTML page, include the SDK using a `<script>` tag:

    ```html theme={null}
    <script src="https://js.radar.com/v5.0.0/radar.min.js"></script>
    ```

    In a web app, install the package from npm, then import the library:

    ```
    npm install --save radar-sdk-js
    ```

    ```
    import Radar from 'radar-sdk-js';
    ```
  </Step>

  <Step title="Call the IP geocoding API">
    The [IP geocoding API](/api#ip-geocode) converts IP address into city, state, and country.

    Initialize the SDK with your publishable API key, then call the IP geocoding API.

    In the callback, `result.address` will include `countryCode`, `stateCode`, `city`, coarse `latitude` and `longitude`, and more.

    ```javascript theme={null}
    Radar.initialize("prj_test_pk_...");

    Radar.ipGeocode(function(err, result) {
      if (err) {
        console.error(err);

        return;
      }

      if (result && result.address) {
        // do something with result.address.countryCode
      }
    });
    ```
  </Step>
</Steps>

## Sample code

```html theme={null}
<html>
  <head>
    <title>Hello, world!</title>
    <script src="https://js.radar.com/v5.0.0/radar.min.js"></script>
  </head>
  <body>
    <div id="country">
      Loading...
    </div>

    <script type="text/javascript">
      Radar.initialize("prj_test_pk_...");

      Radar.ipGeocode(function(err, result) {
        if (err) {
          console.error(err);

          return;
        }

        if (result && result.address) {
          console.log(result.address);

          document.getElementById("country").innerHTML = "Your country is " +
            result.address.countryFlag + " " + result.address.countryCode;
        }
      });
    </script>
  </body>
</html>
```

## Support

Have questions or feedback on this documentation? Let us know! Contact us at [radar.com/support](https://radar.com/support).

[Edit this page](https://github.com/radarlabs/docs/edit/main/docs/tutorials/localizing-a-website-based-on-current-country-or-city.mdx)
