# Consent events and GDPR
> Track GDPR consent preferences, CMP visibility, and marketing consent with enhanced consent events and legacy consent APIs.
> Source: https://docs.snowplow.io/docs/events/ootb-data/consent-events/
> Documentation index: https://docs.snowplow.io/llms.txt

Snowplow provides out-of-the-box [events](/docs/fundamentals/events/) and [entities](/docs/fundamentals/entities/) to track user consent preferences and GDPR compliance. Use these to capture consent decisions, track changes to user preferences, and monitor Consent Management Platform (CMP) performance.

You can also configure your tracker not to track certain identifiers, depending on user consent, using [anonymous tracking](/docs/events/anonymous-tracking/).

## Consent API versions

Snowplow provides two versions of consent tracking APIs:

- Enhanced consent APIs: available for web only using the [Enhanced Consent plugin](/docs/sources/web-trackers/tracking-events/consent-gdpr/), these APIs track detailed consent preferences and CMP visibility events
- Basic consent APIs: available for mobile, these APIs track basic consent activity

To process raw events created by the Snowplow Enhanced Consent plugin, use the consent module in the [Snowplow Unified Digital dbt package](/docs/modeling-your-data/modeling-your-data-with-dbt/dbt-models/dbt-unified-data-model/consent-module/).

> **Note: Models support enhanced consent only**
>
> The Snowplow dbt packages don't support the basic consent events and entities. You can however build your own models based on the raw events.

## Tracker support

This table shows the support for consent tracking across the main client-side Snowplow [tracker SDKs](/docs/sources/). The server-side trackers don't include consent tracking APIs.

Older versions of the web trackers provided the `browser-plugin-consent` plugin for basic consent tracking. It was deprecated in version 4 in favor of `browser-plugin-enhanced-consent`.

| Tracker                                                                            | Supported | Since version                           | Auto-tracking | Notes                                                                               |
| ---------------------------------------------------------------------------------- | --------- | --------------------------------------- | ------------- | ----------------------------------------------------------------------------------- |
| [Web](/docs/sources/web-trackers/tracking-events/consent-gdpr/)                    | ✅         | 3.0.0 - 4.0.0 (basic), 3.8.0 (enhanced) | ✅/❌           | Track enhanced consent events manually; configure automatic addition of GDPR entity |
| [iOS](/docs/sources/mobile-trackers/tracking-events/#creating-a-consent-event)     | ✅         | 1.0.0                                   | ✅/❌           | Track basic consent events manually; configure automatic addition of GDPR entity    |
| [Android](/docs/sources/mobile-trackers/tracking-events/#creating-a-consent-event) | ✅         | 1.0.0                                   | ✅/❌           | Track basic consent events manually; configure automatic addition of GDPR entity    |
| [React Native](/docs/sources/react-native-tracker/tracking-events/)                | ✅         | 1.0.0                                   | ❌             | Basic API\*; no GDPR entity                                                         |
| [Flutter](/docs/sources/flutter-tracker/tracking-events/)                          | ✅         | 0.1.0                                   | ❌             | Basic API                                                                           |
| Roku                                                                               | ❌         |                                         |               | Track custom events using the enhanced schemas                                      |
| [Google Tag Manager](/docs/sources/google-tag-manager/snowplow-template/)          | ✅         | v3                                      | ❌             | Enhanced consent events                                                             |

\*It's also possible to use the JavaScript Enhanced Consent plugin with the React Native tracker.

## Events and entities

This section describes the events and entities used in Snowplow consent tracking.

### Enhanced

The [Enhanced Consent plugin](/docs/sources/web-trackers/tracking-events/consent-gdpr/) includes a number of tracking calls for different user consent actions:

| API                     | To track                                                |
| ----------------------- | ------------------------------------------------------- |
| `trackConsentAllow`     | Acceptance of user consent                              |
| `trackConsentSelected`  | A specific selection of consented scopes                |
| `trackConsentPending`   | The unconfirmed selection about user consent            |
| `trackConsentImplicit`  | The implicit consent on user consent preferences        |
| `trackConsentDeny`      | A denial of user consent                                |
| `trackConsentExpired`   | The expiration of a consent selection                   |
| `trackConsentWithdrawn` | The withdrawal of user consent                          |
| `trackCmpVisible`       | The render time of a consent management platform banner |

With the exception of the CMP visible event, these methods use the same `consent_preferences` event schema. The CMP visible event uses the `cmp_visible` schema.

### `consent_preferences`

**Type:** Event

Schema for consent preferences selection event

**Properties:**

| Property                  | Description                                                                                                                                                                         |
| ------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `eventType` __            | _Required._ The action for the consent preferences of a user. Must be one of: `deny_all`, `allow_all`, `allow_selected`, `pending`, `implicit_consent`, `withdrawn`, `expired`      |
| `basisForProcessing` __   | _Required._ GDPR lawful basis for data collection & processing. Must be one of: `consent`, `contract`, `legal_obligation`, `vital_interests`, `public_task`, `legitimate_interests` |
| `consentUrl` _string_     | _Required._ URI of the privacy policy related document.                                                                                                                             |
| `consentVersion` _string_ | _Required._ Version of the privacy policy related document.                                                                                                                         |
| `consentScopes` _array_   | _Required._ The scopes allowed after the user finalized his selection of consent preferences. E.g \['analytics', 'functional', 'advertisement'].                                    |
| `domainsApplied` _array_  | _Required._ The domains for which this consent allows these preferences to persist to.                                                                                              |
| `gdprApplies` _boolean_   | _Optional._ Determine if GDPR applies based on the user's geo-location.                                                                                                             |

**Example warehouse query (Snowflake):**

```sql
select
unstruct_event_com_snowplowanalytics_snowplow_consent_preferences_1 consent_preferences_1
from
atomic.events
where
events.collector_tstamp > getdate() - interval '1 hour'
and events.event = 'unstruct'
and events.event_name = 'consent_preferences'
and events.event_vendor = 'com.snowplowanalytics.snowplow'
```

### `cmp_visible`

**Type:** Event

Tracks the load time of Consent Management Platform (CMP) banners.

**Properties:**

| Property               | Description                                                                 |
| ---------------------- | --------------------------------------------------------------------------- |
| `elapsedTime` _number_ | _Required._ The time taken for the consent popup to be shown to the screen. |

**Example warehouse query (Snowflake):**

```sql
select
unstruct_event_com_snowplowanalytics_snowplow_cmp_visible_1 cmp_visible_1
from
atomic.events
where
events.collector_tstamp > getdate() - interval '1 hour'
and events.event = 'unstruct'
and events.event_name = 'cmp_visible'
and events.event_vendor = 'com.snowplowanalytics.snowplow'
```

### Basic

When you track a `consent_granted` or `consent_withdrawn` event, the tracker will automatically create and attach a `consent_document` entity.

The [native mobile](/docs/sources/mobile-trackers/tracking-events/gdpr-tracking/) and [Flutter](/docs/sources/flutter-tracker/initialization-and-configuration/) trackers also support automatic addition of the `gdpr` entity to all tracked events. To configure this, provide a `GdprConfiguration` object when setting up a new tracker.

The React Native tracker did include GDPR entity configuration in earlier versions. We [deprecated it in version 4](/docs/sources/react-native-tracker/migration-guides/migrating-from-v2-x-to-v4/).

### `consent_granted`

**Type:** Event

Schema for consent granted

**Properties:**

| Property          | Description |
| ----------------- | ----------- |
| `expiry` _string_ | _Optional._ |

**Example warehouse query (Snowflake):**

```sql
select
unstruct_event_com_snowplowanalytics_snowplow_consent_granted_1 consent_granted_1
from
atomic.events
where
events.collector_tstamp > getdate() - interval '1 hour'
and events.event = 'unstruct'
and events.event_name = 'consent_granted'
and events.event_vendor = 'com.snowplowanalytics.snowplow'
```

### `consent_withdrawn`

**Type:** Event

Schema for consent withdrawn

**Properties:**

| Property        | Description |
| --------------- | ----------- |
| `all` _boolean_ | _Required._ |

**Example warehouse query (Snowflake):**

```sql
select
unstruct_event_com_snowplowanalytics_snowplow_consent_withdrawn_1 consent_withdrawn_1
from
atomic.events
where
events.collector_tstamp > getdate() - interval '1 hour'
and events.event = 'unstruct'
and events.event_name = 'consent_withdrawn'
and events.event_vendor = 'com.snowplowanalytics.snowplow'
```

### `consent_document`

**Type:** Schema

Schema for consent document context

**Properties:**

| Property               | Description |
| ---------------------- | ----------- |
| `id` _string_          | _Required._ |
| `version` _string_     | _Required._ |
| `name` _string_        | _Optional._ |
| `description` _string_ | _Optional._ |

### `gdpr`

**Type:** Schema

Schema for a web page context

**Properties:**

| Property                       | Description                                                                                                                                                                 |
| ------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `basisForProcessing` _string_  | _Required._ GDPR basis for data collection & processing Must be one of: `consent`, `contract`, `legal_obligation`, `vital_interests`, `public_task`, `legitimate_interests` |
| `documentId` _string_          | _Optional._ ID for document detailing basis for processing                                                                                                                  |
| `documentVersion` _string_     | _Optional._ Version of document detailing basis for processing                                                                                                              |
| `documentDescription` _string_ | _Optional._ Description of document detailing basis for processing                                                                                                          |
