getConsent

Functionality

The getConsent function is used to notify the caller about the users consent when it is available, independent of the consent region. It provides a simplified consent state which is either full or no consent. If further consent details are required, use the consent region specific functions.

Syntax

function adconsent()

argument name

type

optional

value

description

argument name

type

optional

value

description

command

string

 

'getConsent'

 

parameter

-

✔️

null | undefined

Not used

callback

function

 

function(result:ConsentData, success:boolean)

The callback function that is called with the function call result and whether or not the call was successful.

ConsentData

ConsentData = { fullConsent: true | false, region: <active consent region> }

ConsentData.fullConsent

When fullConsent is true, it means the user has expressed full consent in the consent zone where he’s in. This might mean different things in the different consent zones, i.e., the user has given consent for all purposes, vendors and publisher purposes in GDPR, or the user simply didn’t oppose the sale of his personal data in CCPA. The exact implications of the full consent given will depend on the applicable regional privacy law - however, the true value means that the user didn’t oppose or restrict the consent in any way.

A false value for the fullConsent means that the user has rejected or restricted the consent in some way. It might be a full or partial rejection.

ConsentData.region

The consent region can have the following values:

  • <empty> (no consent region)

  • 'tcfeuv2' (GDPR)

  • 'uspv1' (CCPA)

Other regions that can appear:

  • 'tcfcav1' (PIPEDA - Canada)

  • 'usnat' (US National)

  • 'usca' (US California)

  • 'usco' (US Colorado)

  • 'usct' (US Connecticut)

  • 'usva' (US Virginia)

  • 'usut' (US Utah)

Description

When the function is called, the callback will be called once AdConsent resolves consent (either by having a previously saved consent or waiting for the user to interact with the GUI when no previous consent was in place). Subsequent calls will be returned immediately.

If for some reason the user reopens the GUI, while in the GUI any calls to getConsent will return the same previous consent value. Only after closing the GUI the consent will be updated and a new call to getConsent will reflect the new value.

Scope

The function can be called as soon as AdConsent is declared on the page, which means it can be called right after AdConsent stub is created. The callback will be called once AdConsent resolves consent for the first time.

Example

adconsent('getConsent', null, function(consent, success) { if (success) { if (consent.fullConsent) { // We have full consent, do whatever that needed consent from the user } else { // We have no full consent, but it might be that we still want to do // some stuff for particular regions. if (consent.region == 'tcfeuv2') { // do something that doesn't need full consent in GDPR } else if (consent.region == 'uspv1') { // do something that doesn't need full consent in CCPA } else { ... } } } });