# Events & Variables

Events are pushed by the Didomi Web SDK to your **tag management system**. Events provide variables that contain the user status on vendors and purposes.

You can then setup your rules based on events and variables to decide whether a tag can be loaded or not directly from your tag manager.

## Events

* `didomi-ready`: This event is pushed exactly once when the page is loaded and can be used for any tag that you want to fire exactly once on the page. The status of the user at the time of this event might be unknown.
* `didomi-consent-changed`: This event is pushed every time the user status changes as the result of a user interacting with the Didomi consent notices or preferences.
* `didomi-consent`: This event is pushed once when the page is loaded and then every time the user status changes as the result of a user interacting with the Didomi consent notices or preferences. Because this event does not distinguish between a page load and a subsequent status change, it can be fired multiple times on the page and is not suited for tags that must be fired at most once. You will usually want to use a combination of the `didomi-ready` and `didomi-consent-changed` events instead for these cases.

## Variables

### Vendors

These variables provide the user status for the vendors configured in your notice.

The user status reported for vendors automatically includes the status for their required purposes. You usually do not have to create a trigger that uses both vendors AND purposes variables: a trigger on vendors is enough.

Example: the vendor ID `google` is only included in the list of enabled vendors, if the user has enabled `google` and every purpose required by that vendor.

<table><thead><tr><th width="298">Variable</th><th>Description</th></tr></thead><tbody><tr><td><code>didomiVendorsEnabled</code></td><td><ul><li>Contains IDs of vendors that are 1) enabled for all their legal bases AND 2) all the defined purposes for the vendor are enabled for all their legal bases.</li><li><code>didomiVendorsEnabled</code> also contains any vendor defined with essential purposes only.</li><li>When no regulation applies to the user, <code>didomiVendorsEnabled</code> contains all vendors defined in your notice configuration.</li></ul></td></tr><tr><td><code>didomiVendorsDisabled</code></td><td><ul><li>Contains IDs of vendors that are either directly disabled by the user OR at least one of their defined purposes is disabled for any legal basis.</li><li>When no regulation applies to the user, <code>didomiVendorsDisabled</code> is empty.</li></ul></td></tr><tr><td><code>didomiVendorsUnknown</code></td><td><ul><li>Contains IDs of vendors that are neither enabled nor disabled (i.e: user has not made a choice and there is no default status for the legal basis).</li><li>When no regulation applies to the current user, <code>didomiVendorsUnknown</code> is empty.</li></ul></td></tr></tbody></table>

**Vendor IDs**

* All variables have the same format: a comma-separated list of vendor IDs terminated by a final comma.
* To find your vendor ID, navigate to the Didomi Console -> Consent notices -> Open your notice -> Regulation -> Edit vendors and Purposes: Use the API ID.
* Vendor IDs are unique and are the same across all regulations and notices.

<figure><img src="https://1703900661-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LDh8ZWDZrXs8sc4QKEQ%2Fuploads%2Fgit-blob-238a0f2edb99544f7f04485b07910f852383d2b2%2FScreenshot%202024-02-19%20at%2009.21.04.png?alt=media" alt=""><figcaption></figcaption></figure>

***

### Purposes

These variables contain the user status for the purposes configured in your notice.

You usually do not need to use these variables directly and want to use the vendors variables instead.

All variables have the same format: a comma-separated list of purpose IDs terminated by a final comma. Example: `cookies,analytics,`

<table data-header-hidden><thead><tr><th width="364">Variable</th><th>Description</th></tr></thead><tbody><tr><td>Variable</td><td>Description</td></tr><tr><td><code>didomiPurposesEnabled</code></td><td><ul><li>List of purposes that are enabled in all the legal bases for which they are defined.</li><li><code>didomiPurposesEnabled</code> also contains any purpose defined as essential on your consent notice.</li><li>When no regulation applies to the user, <code>didomiPurposesEnabled</code> contains all purposes defined in your notice configuration.</li></ul></td></tr><tr><td><code>didomiPurposesDisabled</code></td><td><ul><li>List of purposes that are disabled in any of the legal bases for which they were defined.</li><li>When no regulation applies to the current user, <code>didomiPurposesDisabled</code> is empty.</li></ul></td></tr></tbody></table>

***

### AB tests

We expose variables that contain the status of the AB test running (if any). That allows you to track your AB tests results through your own analytics solution.

| Variable                    | Description                           | Values / Example                                                                                                                                                                                                           |
| --------------------------- | ------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `didomiExperimentId`        | ID of the AB test running.            | The value of the `experiment.id` property in your SDK configuration. An empty string is provided if there is no test configured.                                                                                           |
| `didomiExperimentUserGroup` | The group that the user is a part of. | <p><code>control</code> if the user is part of the control group</p><p><code>test</code> if the user is part of the user group</p><p>An empty string is provided if the user is not part of the control or test group.</p> |

***

### GDPR & IAB

| Variable            | Description                                                                                                                                                                                                                                                                                                                             | Values / Example                                    |
| ------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------- |
| `didomiGDPRApplies` | Define whether the GDPR applies to the current user (ie the user is located in the EU or your website is configured to enforce GDPR for all users).                                                                                                                                                                                     | `0` (GDPR does not apply) and `1` (GDPR does apply) |
| `didomiIABConsent`  | The IAB consent string as defined in the [Consent String and Vendor List Format specification](https://github.com/InteractiveAdvertisingBureau/GDPR-Transparency-and-Consent-Framework). It encodes the consent information for every vendor and purpose as well as few other pieces of information on the CMP that created the string. | `BOMi0lyOMi0lyAHABBENAC-AAAAB4AQABaA`               |


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developers.didomi.io/cmp/web-sdk/third-parties/tags-management/events-and-variables.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
