> For the complete documentation index, see [llms.txt](https://doc.commandersact.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://doc.commandersact.com/fr/fonctionnalites/sources/sources-catalog/web/containers/geoloc-api.md).

# API Geoloc

### Aperçu

Le **Geoloc API** vous permet d’enrichir les données de trafic de votre site web avec des informations géographiques sur vos visiteurs — **sans avoir besoin de l’aide de votre équipe technique**.\
Ce service fournit des attributs de localisation précis tels que :

* Code du continent
* Code pays
* Région
* Ville
* Code postal
* Latitude et longitude

> **Remarque :** Geoloc est une **fonctionnalité optionnelle et facturable**. Veuillez contacter votre **représentant commercial Commanders Act** pour connaître les détails tarifaires.

***

### Fonctionnement

Pour récupérer les données Geoloc, notre système envoie une requête au point de terminaison suivant :

```
https://api.commander1.com/geoloc?token=XXX&site=XXX
```

**Paramètres :**

| Paramètre | Description                                                      |
| --------- | ---------------------------------------------------------------- |
| `token`   | Jeton API fourni par l’équipe support Commanders Act             |
| `site`    | ID du site (espace de travail Commanders Act) qui demande Geoloc |

L’API renvoie un objet JSON contenant les détails géographiques du visiteur.

#### Exemple de réponse

```json
{
  "continentCode": "EU",
  "countryCode": "FR",
  "region": "Île-de-France",
  "longitude": 2.3333,
  "latitude": 48.8667,
  "city": "Paris",
  "postalCode": "75001"
}
```

***

### Utilisation de Geoloc dans votre bloc JavaScript personnalisé

Voici un exemple simple montrant comment appeler l’API et stocker le résultat dans `tC.internalvars` pour une utilisation dans TMS. Vous pouvez utiliser ce code dans votre bloc JavaScript personnalisé.

#### Exemple de script

```javascript
function httpGet(url) {
  var xmlHttp = new XMLHttpRequest();
  xmlHttp.open("GET", url, false); // requête synchrone
  xmlHttp.send(null);
  return JSON.parse(xmlHttp.responseText);
}

tC.internalvars.geoloc = httpGet("https://api.commander1.com/geoloc/?site={YOUR SITE ID}&token={YOUR TOKEN}");
```

Une fois assignée, vous pouvez utiliser n’importe quel champ directement via internalvars

```javascript
tC.internalvars.geoloc.continentCode  // "EU"
tC.internalvars.geoloc.countryCode    // "FR"
tC.internalvars.geoloc.region         // "Île-de-France"
tC.internalvars.geoloc.longitude      // 2.3399
tC.internalvars.geoloc.latitude       // 48.8718
tC.internalvars.geoloc.city           // "Paris"
tC.internalvars.geoloc.postalCode     // "75009"
```

Ces variables peuvent désormais être utilisées pour créer vos propres règles personnalisées, comme afficher une bannière de confidentialité pour différents pays.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://doc.commandersact.com/fr/fonctionnalites/sources/sources-catalog/web/containers/geoloc-api.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
