- getUSPCookieValue([win]) ⇒
String
|null
Get the cookie value for the USP string
- GetConsentDataOptions :
Object
- OnUSPStringOptions :
Object
- ConsentPayload :
Object
- VendorConsentPayload :
Object
- GoogleConsentPayload :
Object
- WaitForConsentDataOptions :
Object
- Mem :
Array
Memoized function collection
- GetConsent
- .exports.getConsentData([options]) ⇒
Promise.<(null|ConsentPayload|VendorConsentPayload|GoogleConsentPayload)>
- .exports.getConsentString([options]) ⇒
Promise.<(String|null)>
- .exports.getGoogleConsent([options]) ⇒
Promise.<(Number|null)>
- .exports.getUSPString([options]) ⇒
Promise.<(String|null)>
- .exports.getVendorConsentData([options]) ⇒
Promise.<(VendorConsentPayload|null)>
- .exports.onConsentData(cb, [options]) ⇒
function
- .exports.onConsentString(cb, [options]) ⇒
function
- .exports.onGoogleConsent(cb, [options]) ⇒
function
- .exports.onUSPString(cb, [options]) ⇒
function
- .exports.onVendorConsent(cb, [options]) ⇒
function
- .exports.createMem() ⇒
Mem
- .exports.uspApplies(str) ⇒
Boolean
- .exports.uspOptsOut(str) ⇒
Boolean
- .exports.getConsentData([options]) ⇒
GetConsent.exports.getConsentData([options]) ⇒ Promise.<(null|ConsentPayload|VendorConsentPayload|GoogleConsentPayload)>
Get consent data from a CMP
Kind: static method of GetConsent
Returns: Promise.<(null|ConsentPayload|VendorConsentPayload|GoogleConsentPayload)>
- A promise that resolves with consent data, or null if appropriate
Param | Type | Description |
---|---|---|
[options] | GetConsentDataOptions |
Options for the CMP/consent request |
Get the current consent string, if available
Kind: static method of GetConsent
Param | Type | Description |
---|---|---|
[options] | GetConsentDataOptions |
Options for the lookup |
Get the current Google consent state, if available
Kind: static method of GetConsent
Returns: Promise.<(Number|null)>
- Returns 1 or 0 for Google consent,
or null if not available and specified not to throw
Param | Type | Description |
---|---|---|
[options] | GetConsentDataOptions |
Options for the lookup |
Get the USP string, if available (CCPA)
Kind: static method of GetConsent
Returns: Promise.<(String|null)>
- The USP string if found or
null
Param | Type | Description |
---|---|---|
[options] | GetConsentDataOptions |
Options for the lookup |
Get the current vendors consent state, if available
Kind: static method of GetConsent
Param | Type | Description |
---|---|---|
[options] | GetConsentDataOptions |
Options for the lookup |
Listen for consent data and fire a callback once received
Kind: static method of GetConsent
Returns: function
- Function to call to stop listening
Param | Type | Description |
---|---|---|
cb | function |
The callback to fire - receives the ConsentPayload |
[options] | GetConsentDataOptions |
Options for the lookup |
Example
const remove = onConsentData(
(err, data) => {
if (err) {
console.error(err);
} else {
console.log("Consent payload:", data);
}
},
{ win: window.top }
);
// Later:
remove();
Listen for consent data and fire a callback with the consent string once received
Kind: static method of GetConsent
Returns: function
- Removal function
Param | Type | Description |
---|---|---|
cb | function |
Callback to fire - receives just the consent string or an error if not avail. |
[options] | GetConsentDataOptions |
Listen for consent data and fire a callback with the consent string once received
Kind: static method of GetConsent
Returns: function
- Removal function
Param | Type | Description |
---|---|---|
cb | function |
Callback to fire - receives just the consent string or an error if not avail. |
[options] | GetConsentDataOptions |
Listen for a USP string and fire a callback with the privacy string once received
Kind: static method of GetConsent
Returns: function
- Removal function
Param | Type | Description |
---|---|---|
cb | function |
Callback to fire - called with (error, uspString): error if failed, or null and with uspString as following argument |
[options] | OnUSPStringOptions |
Listen for consent data and fire a callback with vendor consent data once received
Kind: static method of GetConsent
Returns: function
- Removal function
Param | Type | Description |
---|---|---|
cb | function |
Callback to fire - receives vendor consent data or an error if not avail. |
[options] | GetConsentDataOptions |
GetConsent.exports.createMem() ⇒ Mem
Create a new memoization instance
Kind: static method of GetConsent
Detect whether or not a value is indicative of USP applying to the user (does not detect whether or not the string disables data sales).
Kind: static method of GetConsent
Returns: Boolean
- Whether or not a value is a
USP string and whether or not USP applies due
to it
See: uspOptsOut
Param | Type | Description |
---|---|---|
str | String | * |
The USP string or value |
Example
uspApplies("1---") // false
uspApplies("1YN-") // true
Detect whether or not a USP string opts a user out of data sales.
Kind: static method of GetConsent
Returns: Boolean
- True if the value is a USP
string that opts the user out from the sale
of their data
Param | Type | Description |
---|---|---|
str | String | * |
The USP string or value |
Example
uspOptsOut("1---") // false
uspOptsOut("1YYN") // true
Get the cookie value for the USP string
Kind: global function
Returns: String
| null
- The USP string or null if
not found
Param | Type | Description |
---|---|---|
[win] | Window |
Optional window override |
Kind: global typedef
Properties
Name | Type | Description |
---|---|---|
[mem] | Mem |
Memoization collection for caching results |
[noConsent] | String |
Action to take when no consent or fetching times-out. When set to "reject" (default), an error is thrown. When set to "resolve", null is returned. |
timeout | Number | null |
Timeout in milliseconds. Defaults to null (no timeout). |
[type] | String |
Type of consent data to fetch. Defaults to "" (generic CMP consent data). Can be set to "google" for Google consent data, "usp" for USP strings or "vendor" for vendors consent data. |
[win] | Window |
Optional window override. |
Kind: global typedef
Properties
Name | Type | Description |
---|---|---|
[mem] | Mem |
Optional mem instance override |
[win] | Window |
Optional window instance override |
Kind: global typedef
Properties
Name | Type | Description |
---|---|---|
consentData | String |
Consent string for the user |
gdprApplies | Boolean |
Whether or not GDPR consent applies for this particular user |
hasGlobalConsent | Boolean |
? |
hasGlobalScope | Boolean |
Whether or not the publisher is participating in the global scope for the IAB's consent framework |
Kind: global typedef
Properties
Name | Type | Description |
---|---|---|
gdprApplies | Boolean |
Whether or not GDPR consent applies for this particular user |
hasGlobalConsent | Boolean |
? |
hasGlobalScope | Boolean |
Whether or not the publisher is participating in the global scope for the IAB's consent framework |
metadata | String |
Base64 encoded header information |
purposeConsents | Object.<String, Boolean> |
Key-value list of purposes that the user has consented to. Key is a purpose ID, value is whether or not consent was granted. |
vendorConsents | Object.<String, Boolean> |
Key-value list of vendor IDs that the user has consented to |
Kind: global typedef
Properties
Name | Type | Description |
---|---|---|
googlePersonalizationData | Object |
Data related to Google personalization state |
googlePersonalizationData.consentValue | Number |
Either 1 or 0, indicating whether or not Google personalization consent was granted |
googlePersonalizationData.created | Date | null |
When the consent state was created for this user |
googlePersonalizationData.lastUpdated | Date | null |
When the consent state was last updated for this user |
Kind: global typedef
Properties
Name | Type | Description |
---|---|---|
[cmpCmd] | String |
CMP command to execute (default: "getConsentData") |
cmpParam | null | Boolean |
Extra parameter to send to CMP (default: null). If set to false it will not be provided in the __cmp call. |
[validate] | Boolean |
Validate CMP payload (only necessary for "getConsentData") (default: true) |
[win] | Window |
Optional window reference override |
Memoized function collection
Kind: global typedef