Consent events (Enhanced Consent)
Enhanced consent is the recommended way to track marketing consent events on your website.
Eventsโ
Schema for consent preferences selection event
Schema URI:iglu:com.snowplowanalytics.snowplow/consent_preferences/jsonschema/1-0-0
Web | Mobile | Tracked automatically |
---|---|---|
โ | โ | โ |
๐ Example
{
"basisForProcessing": "consent",
"consentVersion": "1",
"consentScopes": [
"necessary",
"preferences",
"statistics"
],
"domainsApplied": [
"https://www.example.com/"
],
"consentUrl": "https://www.example.com/",
"eventType": "allow_selected",
"gdprApplies": false
}
๐ Schema properties definition
- Table
- JSON schema
Property | Type | Description | Required? |
---|---|---|---|
eventType | One of: deny_all, allow_all, allow_selected, pending, implicit_consent, withdrawn, expired | The action for the consent preferences of a user. | โ |
basisForProcessing | One of: consent, contract, legal_obligation, vital_interests, public_task, legitimate_interests | GDPR lawful basis for data collection & processing. | โ |
consentUrl | "string" | URI of the privacy policy related document. | โ |
consentVersion | "string" | Version of the privacy policy related document. | โ |
consentScopes | "array" | The scopes allowed after the user finalized his selection of consent preferences. E.g ['analytics', 'functional', 'advertisement']. | โ |
domainsApplied | "array" | The domains for which this consent allows these preferences to persist to. | โ |
gdprApplies | ["boolean","null"] | Determine if GDPR applies based on the user's geo-location. | โ |
{
"$schema": "http://iglucentral.com/schemas/com.snowplowanalytics.self-desc/schema/jsonschema/1-0-0#",
"description": "Schema for consent preferences selection event",
"self": {
"vendor": "com.snowplowanalytics.snowplow",
"name": "consent_preferences",
"format": "jsonschema",
"version": "1-0-0"
},
"type": "object",
"properties": {
"eventType": {
"enum": [
"deny_all",
"allow_all",
"allow_selected",
"pending",
"implicit_consent",
"withdrawn",
"expired"
],
"description": "The action for the consent preferences of a user."
},
"basisForProcessing": {
"enum": [
"consent",
"contract",
"legal_obligation",
"vital_interests",
"public_task",
"legitimate_interests"
],
"description": "GDPR lawful basis for data collection & processing."
},
"consentUrl": {
"type": "string",
"format": "uri",
"description": "URI of the privacy policy related document."
},
"consentVersion": {
"type": "string",
"maxLength": 16,
"description": "Version of the privacy policy related document."
},
"consentScopes": {
"type": "array",
"items": {
"type": "string",
"description": "Each consent scope which has been accepted.",
"maxLength": 1024
},
"minItems": 1,
"description": "The scopes allowed after the user finalized his selection of consent preferences. E.g ['analytics', 'functional', 'advertisement']."
},
"domainsApplied": {
"type": "array",
"items": {
"type": "string",
"description": "Each domain for which consent action applies.",
"maxLength": 1024
},
"minItems": 1,
"description": "The domains for which this consent allows these preferences to persist to."
},
"gdprApplies": {
"type": [
"boolean",
"null"
],
"description": "Determine if GDPR applies based on the user's geo-location."
}
},
"required": [
"eventType",
"consentVersion",
"domainsApplied",
"consentScopes",
"consentUrl",
"basisForProcessing"
],
"additionalProperties": false
}
โ How to query the event in the warehouse?
- Snowflake
- BigQuery
- Databricks
- Redshift & Postgres
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'
select
unstruct_event_com_snowplowanalytics_snowplow_consent_preferences_1_0_0
from
PIPELINE_NAME.events events
where
events.collector_tstamp > timestamp_sub(current_timestamp(), interval 1 hour)
and events.event = 'unstruct'
and events.event_name = 'consent_preferences'
and events.event_vendor = 'com.snowplowanalytics.snowplow'
select
unstruct_event_com_snowplowanalytics_snowplow_consent_preferences_1
from
atomic.events events
where
events.collector_tstamp > timestampadd(HOUR, -1, current_timestamp())
and events.event = 'unstruct'
and events.event_name = 'consent_preferences'
and events.event_vendor = 'com.snowplowanalytics.snowplow'
and unstruct_event_com_snowplowanalytics_snowplow_consent_preferences_1 is not null
select
"consent_preferences_1".*
from
atomic.events events
join atomic.com_snowplowanalytics_snowplow_consent_preferences_1 "consent_preferences_1"
on "consent_preferences_1".root_id = events.event_id and "consent_preferences_1".root_tstamp = events.collector_tstamp
where
events.collector_tstamp > getdate() - interval '1 hour'
and "consent_preferences_1".root_tstamp > getdate() - interval '1 hour'
and events.event = 'unstruct'
and events.event_name = 'consent_preferences'
and events.event_vendor = 'com.snowplowanalytics.snowplow'
Tracks the load time of Consent Management Platform (CMP) banners.
Schema URI:iglu:com.snowplowanalytics.snowplow/cmp_visible/jsonschema/1-0-0
Web | Mobile | Tracked automatically |
---|---|---|
โ | โ | โ |
๐ Example
{
"elapsedTime": 1.5
}
๐ Schema properties definition
- Table
- JSON schema
Property | Type | Description | Required? |
---|---|---|---|
elapsedTime | "number" | The time taken for the consent popup to be shown to the screen. | โ |
{
"$schema": "http://iglucentral.com/schemas/com.snowplowanalytics.self-desc/schema/jsonschema/1-0-0#",
"description": "Schema for consent dialog shown event",
"self": {
"vendor": "com.snowplowanalytics.snowplow",
"name": "cmp_visible",
"format": "jsonschema",
"version": "1-0-0"
},
"type": "object",
"properties": {
"elapsedTime": {
"type": "number",
"description": "The time taken for the consent popup to be shown to the screen.",
"maximum": 9223372036854776000,
"minimum": 0
}
},
"required": [
"elapsedTime"
],
"additionalProperties": false
}
โ How to query the event in the warehouse?
- Snowflake
- BigQuery
- Databricks
- Redshift & Postgres
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'
select
unstruct_event_com_snowplowanalytics_snowplow_cmp_visible_1_0_0
from
PIPELINE_NAME.events events
where
events.collector_tstamp > timestamp_sub(current_timestamp(), interval 1 hour)
and events.event = 'unstruct'
and events.event_name = 'cmp_visible'
and events.event_vendor = 'com.snowplowanalytics.snowplow'
select
unstruct_event_com_snowplowanalytics_snowplow_cmp_visible_1
from
atomic.events events
where
events.collector_tstamp > timestampadd(HOUR, -1, current_timestamp())
and events.event = 'unstruct'
and events.event_name = 'cmp_visible'
and events.event_vendor = 'com.snowplowanalytics.snowplow'
and unstruct_event_com_snowplowanalytics_snowplow_cmp_visible_1 is not null
select
"cmp_visible_1".*
from
atomic.events events
join atomic.com_snowplowanalytics_snowplow_cmp_visible_1 "cmp_visible_1"
on "cmp_visible_1".root_id = events.event_id and "cmp_visible_1".root_tstamp = events.collector_tstamp
where
events.collector_tstamp > getdate() - interval '1 hour'
and "cmp_visible_1".root_tstamp > getdate() - interval '1 hour'
and events.event = 'unstruct'
and events.event_name = 'cmp_visible'
and events.event_vendor = 'com.snowplowanalytics.snowplow'
How to track?โ
To track enhanced consent events using the JavaScript tracker on Web, you can make use of the Enhanced Consent plugin.
Modeled data using the snowplow-web dbt packageโ
To process raw events created by the Snowplow Enhanced Consent plugin we have included an optional module to model consent events in the snowplow-web dbt package.
This custom module consists of a series of dbt models which produce the following aggregated models from the raw consent tracking events:
Derived table | Table description | |
---|---|---|
snowplow_web_consent_log | Snowplow incremental table showing the audit trail of consent and Consent Management Platform (cmp) events | Docs |
snowplow_web_consent_users | Incremental table of user consent tracking stats | Docs |
snowplow_web_consent_totals | Summary of the latest consent status, per consent version | Docs |
snowplow_web_consent_scope_status | Aggregate of current number of users consented to each consent scope | Docs |
snowplow_web_cmp_stats | Used for modeling cmp_visible events and related metrics | Docs |
snowplow_web_consent_versions | Incremental table used to keep track of each consent version and its validity | Docs |
Consent Tracking for Marketing acceleratorโ
Visit the Consent Tracking for Marketing accelerator for an end-to-end tutorial on how to track and model consent data using Snowplow.
Older consent APIs and events
There is an option to track older consent granted and consent withdrawn events in our trackers. However, we recommend using the Enhanced Consent events as they are more up-to-date.
To learn how to track consent granted and withdrawn events, see:
- On Web, make use of the Consent plugin on the JavaScript tracker.
- On mobile, see the consent tracking APIs here.
The tracking consists of two events (consent_granted
and consent_withdrawn
) and two context entities (consent_document
and gdpr
).
Schema for consent granted
Schema URI:iglu:com.snowplowanalytics.snowplow/consent_granted/jsonschema/1-0-0
๐ Schema properties definition
- Table
- JSON schema
Property | Type | Description | Required? |
---|---|---|---|
expiry | "string" | โ |
{
"$schema": "http://iglucentral.com/schemas/com.snowplowanalytics.self-desc/schema/jsonschema/1-0-0#",
"description": "Schema for consent granted",
"self": {
"vendor": "com.snowplowanalytics.snowplow",
"name": "consent_granted",
"format": "jsonschema",
"version": "1-0-0"
},
"type": "object",
"properties": {
"expiry": {
"type": "string",
"format": "date-time"
}
},
"additionalProperties": false
}
Schema for consent withdrawn
Schema URI:iglu:com.snowplowanalytics.snowplow/consent_withdrawn/jsonschema/1-0-0
๐ Schema properties definition
- Table
- JSON schema
Property | Type | Description | Required? |
---|---|---|---|
all | "boolean" | โ |
{
"$schema": "http://iglucentral.com/schemas/com.snowplowanalytics.self-desc/schema/jsonschema/1-0-0#",
"description": "Schema for consent withdrawn",
"self": {
"vendor": "com.snowplowanalytics.snowplow",
"name": "consent_withdrawn",
"format": "jsonschema",
"version": "1-0-0"
},
"type": "object",
"properties": {
"all": {
"type": "boolean"
}
},
"required": [
"all"
],
"additionalProperties": false
}
Schema for consent document context
Schema URI:iglu:com.snowplowanalytics.snowplow/consent_document/jsonschema/1-0-0
๐ Schema properties definition
- Table
- JSON schema
Property | Type | Description | Required? |
---|---|---|---|
id | "string" | โ | |
version | "string" | โ | |
name | "string" | โ | |
description | "string" | โ |
{
"$schema": "http://iglucentral.com/schemas/com.snowplowanalytics.self-desc/schema/jsonschema/1-0-0#",
"description": "Schema for consent document context",
"self": {
"vendor": "com.snowplowanalytics.snowplow",
"name": "consent_document",
"format": "jsonschema",
"version": "1-0-0"
},
"type": "object",
"properties": {
"id": {
"type": "string",
"maxLength": 36
},
"version": {
"type": "string",
"maxLength": 36
},
"name": {
"type": "string",
"maxLength": 60
},
"description": {
"type": "string",
"maxLength": 10000
}
},
"required": [
"id",
"version"
],
"additionalProperties": false
}
Schema for a web page context
Schema URI:iglu:com.snowplowanalytics.snowplow/gdpr/jsonschema/1-0-0
๐ Schema properties definition
- Table
- JSON schema
Property | Type | Description | Required? |
---|---|---|---|
basisForProcessing | One of: consent, contract, legal_obligation, vital_interests, public_task, legitimate_interests | GDPR basis for data collection & processing | โ |
documentId | ["string","null"] | ID for document detailing basis for processing | โ |
documentVersion | ["string","null"] | Version of document detailing basis for processing | โ |
documentDescription | ["string","null"] | Description of document detailing basis for processing | โ |
{
"$schema": "http://iglucentral.com/schemas/com.snowplowanalytics.self-desc/schema/jsonschema/1-0-0#",
"description": "Schema for a web page context",
"self": {
"vendor": "com.snowplowanalytics.snowplow",
"name": "gdpr",
"format": "jsonschema",
"version": "1-0-0"
},
"type": "object",
"properties": {
"basisForProcessing": {
"type": "string",
"enum": [
"consent",
"contract",
"legal_obligation",
"vital_interests",
"public_task",
"legitimate_interests"
],
"description": "GDPR basis for data collection & processing"
},
"documentId": {
"type": [
"string",
"null"
],
"maxLength": 255,
"description": "ID for document detailing basis for processing"
},
"documentVersion": {
"type": [
"string",
"null"
],
"maxLength": 16,
"description": "Version of document detailing basis for processing"
},
"documentDescription": {
"type": [
"string",
"null"
],
"maxLength": 4096,
"description": "Description of document detailing basis for processing"
}
},
"required": [
"basisForProcessing"
],
"additionalProperties": false
}