Skip to main content

Enhanced Consent

This plugin is the recommended way to track marketing consent events on your website. Functions, usage and a complete setup journey is showcased on the Consent Tracking for Marketing accelerator.

Tracker DistributionIncluded
sp.js
sp.lite.js
note

The plugin is available since version 3.8 of the tracker.

Download

Download from GitHub Releases (Recommended)Github Releases (plugins.umd.zip)
Available on jsDelivrjsDelivr (latest)
Available on unpkgunpkg (latest)

Initialization

window.snowplow(
'addPlugin',
'https://cdn.jsdelivr.net/npm/@snowplow/browser-plugin-enhanced-consent@latest/dist/index.umd.min.js',
['snowplowEnhancedConsentTracking', 'EnhancedConsentPlugin']
);

Functions

APIUsed for:
trackConsentAllowTrack an acceptance of user consent.
trackConsentSelectedTrack a specific selection of consented scopes.
trackConsentPendingTrack the unconfirmed selection about user consent.
trackConsentImplicitTrack the implicit consent on user consent preferences.
trackConsentDenyTrack a denial of user consent.
trackConsentExpiredTrack the expiration of a consent selection.
trackConsentWithdrawnTrack the withdrawal of user consent.
trackCmpVisibleTrack the render time of a CMP banner.

Usage

trackConsentAllow

To track the complete acceptance of a user consent prompt, you can use the trackConsentAllow method with the following attributes:

window.snowplow("trackConsentAllow:{trackerName}", {
consentScopes: ["necessary", "marketing", "personalization"],
basisForProcessing: "consent",
consentUrl: "https://www.example.com/",
consentVersion: "1.0",
domainsApplied: ["https://www.example.com/"],
gdprApplies: true
});

trackConsentSelected

To track the specific selection of scopes of a user consent preferences, you can use the trackConsentSelected method with the following attributes:

window.snowplow("trackConsentSelected:{trackerName}", {
consentScopes: ["necessary", "marketing", "personalization"],
basisForProcessing: "consent",
consentUrl: "https://www.example.com/",
consentVersion: "1.0",
domainsApplied: ["https://www.example.com/"],
gdprApplies: true
});

trackConsentPending

Some consent management platform installations, allow the user to take website actions or/and navigating to other pages without accepting the consent prompt. To track the unconfirmed selection of user consent, you can use the trackConsentPending method with the following attributes:

window.snowplow("trackConsentPending:{trackerName}", {
consentScopes: ["necessary", "marketing", "personalization"],
basisForProcessing: "consent",
consentUrl: "https://www.example.com/",
consentVersion: "1.0",
domainsApplied: ["https://www.example.com/"],
gdprApplies: true
});

trackConsentImplicit

Some consent management platforms have a configuration which allows the setting of consent implicitly after a set of user interactions like clicks, scroll etc. To track the implicit selection of a user consent, you can use the trackConsentImplicit method with the following attributes:

window.snowplow("trackConsentImplicit:{trackerName}", {
consentScopes: ["necessary", "marketing", "personalization"],
basisForProcessing: "consent",
consentUrl: "https://www.example.com/",
consentVersion: "1.0",
domainsApplied: ["https://www.example.com/"],
gdprApplies: true
});

trackConsentDeny

To track the complete denial of a user consent, you can use the trackConsentDeny method with the following attributes:

window.snowplow("trackConsentDeny:{trackerName}", {
consentScopes: ["necessary"],
basisForProcessing: "consent",
consentUrl: "https://www.example.com/",
consentVersion: "1.0",
domainsApplied: ["https://www.example.com/"],
gdprApplies: true
});

trackConsentExpired

To track the expiration of a user consent, you can use the trackConsentExpired method with the following attributes:

window.snowplow("trackConsentExpired:{trackerName}", {
consentScopes: ["necessary", "marketing", "personalization"],
basisForProcessing: "consent",
consentUrl: "https://www.example.com/",
consentVersion: "1.0",
domainsApplied: ["https://www.example.com/"],
gdprApplies: true
});

trackConsentWithdrawn

To track the withdrawal of a user consent, you can use the trackConsentWithdrawn method with the following attributes:

window.snowplow("trackConsentWithdrawn:{trackerName}", {
consentScopes: ["necessary", "marketing", "personalization"],
basisForProcessing: "consent",
consentUrl: "https://www.example.com/",
consentVersion: "1.0",
domainsApplied: ["https://www.example.com/"],
gdprApplies: true
});

trackCmpVisible

Consent management platform banners are an important part of a website’s first impression and performance. Snowplow provides a way to track what we call elapsedTime, which is the timestamp of the consent management platform banner becoming visible on the user’s screen.

window.snowplow("trackCmpVisible:{trackerName}", {
/* Using the performance.now API to retrieve the elapsed time from the page navigation. */
elapsedTime: performance.now(),
});

Entities

Below is main entity used for tracking consent in the Snowplow Enhanced Consent implementation.

An consent entity can have the following attributes:

attributetypedescriptionrequired
basisForProcessingstringGDPR lawful basis for data collection & processing.
consentUrlstringURI of the privacy policy related document.
consentVersionstringVersion of the privacy policy related document.
consentScopesstring[]The scopes allowed after the user finalized his selection of consent preferences. E.g ['analytics', 'functional', 'advertisement'].
domainsAppliedstring[]The domains for which this consent allows these preferences to persist to.
gdprAppliesbooleanDetermine if GDPR applies based on the user's geo-location.
Relevant Iglu schema
Was this page helpful?