# Consent

## `this.package.consent` Variable

The `this.package.consent` variable provides access to the **temporary consent state** associated with the **currently tracked request**.

> ⚠️ This **does not represent the full or current consent state** for all tools. Instead, it contains only the **temporary consent state** relevant to the **ongoing tracking event** (e.g., a change in consent status).

***

### Purpose

This variable is primarily used to:

* Identify **which tool’s consent state has changed**
* React to **user consent decisions** within the current tracking payload
* Implement **trigger logic** based on consent transitions (e.g., granted/declined)

***

### Variable Definition

| Property          | Description                                                |
| ----------------- | ---------------------------------------------------------- |
| **Variable Name** | `this.package.consent`                                     |
| **Type**          | `JSON` (key-value pairs of tool/vendor and consent status) |
| **Example Value** | `{ "googleanalytics": true, "facebook": "ncm" }`           |
| **Scope**         | Available in **server-side variables**                     |

***

### Consent Values

Each key in the JSON represents a **vendor/tool name** (e.g., `googleanalytics`, `facebook`) and its value indicates the **temporary consent status**:

| Value   | Meaning                            |
| ------- | ---------------------------------- |
| `true`  | Consent **granted**                |
| `false` | Consent **declined**               |
| `"ncm"` | Tool running in **Essential Mode** |

***

### Example Usage

```js
async function() {
    var x = this.package.consent.googleanalytics; // true || false || "ncm"
    return x;
}
```

This example reads the current temporary consent state for `googleanalytics`.

***

### Important Notes

* This variable **does not represent the full consent history or state**.
* It reflects the **temporal** or **transitional consent status** — i.e., only the **changed consent** at the time of this tracking event.
* To understand the full consent behavior, refer to the J-Tracker Course or consult with your JENTIS integration specialist.

***

#### Simplified Example

Imagine the following sequence of user interactions:

1. **User gives consent only to Google Analytics (GA)**\
   → `this.package.consent = { "googleanalytics": true }`
2. **User then adds Facebook consent later (same page)**\
   → `this.package.consent = { "facebook": true }`

This results in **multiple packages**, each reflecting the **current consent change**, not the full state:

```json
// Tracking Event 1
{ "googleanalytics": true }

// Tracking Event 2
{ "facebook": true }
```

> The full consent state is stored and managed separately.

***

### Use Cases

* Trigger actions only when a specific tool’s consent has changed
* Capture analytics around consent transitions
* Customize logic for tools entering `"ncm"` (Essential Mode)

***

### Summary

`this.package.consent` gives you insight into the **temporary, event-specific consent state** for each vendor. It's a powerful variable for building responsive, consent-aware tracking flows in JENTIS.
