> 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/consent-management/onsite-api/consent.onready.md).

# consent.onReady

Méthode pour obtenir le consentement Commanders Act lorsqu'il devient disponible.

{% hint style="info" %}
Méthode permettant d’obtenir le consentement dès qu’il est disponible. Le [stub de l’API OnSite](https://doc.commandersact.com/fr/fonctionnalites/consent-management/onsite-api/getting-started.md) Commanders Act doit être installé avant d’utiliser les fonctions de l’API OnSite.
{% endhint %}

```javascript
cact('consent.onReady', function (result) { ... })
```

La méthode `consent.onReady` permet de s’abonner à une fonction de rappel qui sera exécutée lorsque le consentement sera défini. Cette fonction de rappel ne sera appelée qu’une seule fois, avec l’objet Consent mis à jour. Elle est appelée lorsque le consentement est défini à la suite d’une interaction avec la bannière de consentement ou lorsqu’un cookie de consentement est déjà défini.

Comme pour la commande `consent.onUpdate`, l’argument `consentObject` sera enrichi de la propriété `updateEvent`, mais uniquement avec la valeur « `set`'.

## Exemple

### Exemple d’attente de la disponibilité du consentement et d’exécution d’une action pour une catégorie spécifique

Dans cet exemple, le code attend que l’utilisateur interagisse avec la bannière de consentement. La catégorie Analytics a été configurée avec l’ID de catégorie de consentement 2 dans la bannière de confidentialité.

```javascript
cact('consent.onReady', function (result) { 
    
    var ANALYTICS_ID = 2;
    var analyticsCategory = result.consent.categories[ANALYTICS_ID] || {};
     
    if (analyticsCategory.status === 'on') {
    
        // Le consentement a été donné pour cette catégorie. 
    
    } else {
        
        // Le consentement n’a pas été donné pour cette catégorie. 
           
    }
    
});

```

{% hint style="warning" %}
Au niveau du conteneur, consent.onReady ne peut pas fonctionner avec une catégorie bloquée. Les catégories bloquées sont définies dans la bannière. Pour ce cas d’utilisation spécifique, nous recommandons d’utiliser la méthode consent.get.
{% endhint %}


---

# 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/consent-management/onsite-api/consent.onready.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.
