When Consent Changes
Overview
When a user updates their consent choices or interacts with the OT SDK UI, the application needs to become aware so that it can control the next set of actions like:
- Allowing or restricting processing of third-party SDKs based on their categorization.
- Passing the latest user consent values to third-party SDKs.
- Passing the IAB's encoded TC String to third-party SDKs.
- Passing the IAB's USP String to third-party SDKs.
- Routing the user to another location in the application.
- Displaying messages to the user about their changes.
- Logging updates to internally owned APIs, etc.
Querying for Consent
You can query for consent on a category or SDK level.
Querying Consent Status for a Category
Query the current consent status for any of the categories included in your application. This can be used to determine what privacy action is needed at the time of query and can also be linked with an event listener. Simply pass in the Category ID (eg. C0001) and the method will return the current consent status (integer value).
Value Returned
1
= Consent is given.0
= Consent is not given.-1
= Consent has not been collected (The SDK is not initialized or category does not exist, or there are no SDKs associated to this category).
m.global.OTsdk.callFunc("getConsentStatusForGroupID","C0001")
m.global.OTsdk.callFunc("getConsentStatusForGroupID","C0002")
m.global.OTsdk.callFunc("getConsentStatusForGroupID","C0003")
m.global.OTsdk.callFunc("getConsentStatusForGroupID","C0004")
m.global.OTsdk.callFunc("getConsentStatusForGroupID","C0005")
Parameters
GroupID
: This is the ID for the categories in scope. It can be found in the application navigating to: Cookie Consent > Categorizations > Categories.
Querying Consent Status for a specific SDK
Query the current consent status for any of the SDKs included in your application. This can be used to determine what privacy action is needed at application launch or anytime the consent status is needed without being notified by an event broadcast. Pass in the SDK ID and the method will return the current consent status (integer value).
Value Returned
1
= Consent is given.0
= Consent is not given.-1
= Consent has not been collected (The SDK is not initialized or there are no SDKs associated to this category).
You can find SDK IDs in Cookie Consent > SDKs > Your app.
m.global.OTsdk.callFunc("getConsentStatusForSDKId", "018dcc15-9f1b-7329-88bc-db0d09d28eb4")
Parameters
SDKId
: This is the ID for the SDKs assigned to your app. It can be found under Cookie Consent > SDKs > Your app > Instructions.
Querying Consent for Vendors
If your app includes a list of vendors such as IAB vendors or Google vendors that you need to account for in terms of consent, you query for the status on a vendor level.
Value Returned
2
= Vendor mapped to an always active category (e.g. Strictly Necessary).1
= Consent is given.0
= Consent is not given.
Parameters
The method takes in two parameters:
OTVendorListMode
(type of vendor list to retrieve)google
: returns a list of Google vendors.iab
: returns a list of IAB vendors.
VendorID
Vendor IDs can be found in Cookie Consent > Setup > Vendors.
IAB Vendor
// example for getting IAB vendor consent value
m.global.OTsdk.callFunc("getConsentStatusForVendorId", "iab", "8")
Google Vendor
// example for getting Google vendor consent value
m.global.OTsdk.callFunc("getConsentStatusForVendorId", "google", "8")
Recommended approaches
- Set an observer to listen for the OTConsentUpdated event listener. In the callback, query for vendor consent.
- Use one of the UI interaction Listener events (such as allSDKViewsDismissed) and query for vendor consent when it is triggered.
Listening for Consent Updates
When consent is updated, the OTConsentUpdated field is updated. This can be observed with a callback, where the consent status is then queried.
m.global.OTsdk.eventlistener.observeField("OTConsentUpdated "," onOTConsentUpdated ")
function onOTConsentUpdated()
sdkStatus = m.global.OTsdk.callFunc("getConsentStatusForGroupID","C0002")
print "sdkStatus -> " sdkStatus
end function
Listening for UI Interaction Events
UI Interaction Events are only relevant if the app is using the out of the box OneTrust UI. If you have built your own UO, disregard this section.
When a user interacts with the OT SDK UI, the SDK sends an interaction event that the application can listen for and action on.
Use case 1
The app needs to trigger certain actions based on interaction with the UI.
Use case 2
In the event that broadcasts cannot be used to action on consent, the app can rely solely on interaction events and querying for consent to fire/suppress SDKs.
Example 1
User selects the Confirm My Choices button on the preference center UI, which saves their consent choices. An app might want to listen for onPreferenceCenterConfirmChoices() to show a success toaster to the user and navigate them to the app's home page.
Example 2
In line of broadcast events, the app can listen for allSDKViewsDismissed and OTConsentUpdated to know when the OneTrust UI has been dismissed and query for user consent. It can then use this consent to fire/suppress SDKs.
Types of Events
Event | Description |
---|---|
onShowBanner | Triggered when banner is shown. |
onHideBanner | Triggered when banner is closed. |
onBannerClickedAcceptAll | Triggered when user allows all consent from banner. |
onBannerClickedRejectAll | Triggered when user rejects all consent from banner. |
onBannerClickedClose | Triggered when user closes from banner. |
onShowPreferenceCenter | Triggered when preference center is displayed. |
onHidePreferenceCenter | Triggered when preference center is closed. |
onPreferenceCenterAcceptAll | Triggered when user allows all consent from preference center. |
onPreferenceCenterRejectAll | Triggered when user rejects all consent from preference center. |
onPreferenceCenterConfirmChoices | Triggered when user clicked on save choices after updating consent values from preference center. |
onPreferenceCenterClose | Triggered when user closes from preference center. |
onShowVendorList | Triggered when vendor list UI is displayed from an IAB banner / IAB preference center. |
onHideVendorList | Triggered when vendor list UI is closed or when back button is clicked. |
onVendorListAcceptAll | Triggered when user allows all consent from vendor list. |
onVendorListRejectAll | Triggered when user rejects all consent from vendor list. |
onVendorConfirmChoices | Triggered when user updates vendor consent / legitimate interests purpose values and save the choices from vendor list. |
onVendorListVendorConsentChanged | Triggered when user updates consent values for a particular vendor ID on Vendor List UI. |
onVendorListVendorLegitimateInterestChanged | Triggered when user updates legitimate interests values for a particular vendor id on Vendor List UI. |
onPreferenceCenterPurposeConsentChanged | Triggered when user updates consent values for a particular category on preference center UI. |
onPreferenceCenterPurposeLegitimateInterestChanged | Triggered when user updates legitimate interest values for a particular category on preference center UI. |
onShowSDKList | Triggered when the SDK List UI is displayed. |
onHideSDKList | Triggered when the SDK List UI is closed or when back button is clicked. |
onSDKListConfirmChoices | Triggered when user updates SDK consent and save the choices from SDK List. |
onSDKListAcceptAll | Triggered when user allows all consent from SDK List. |
onSDKListRejectAll | Triggered when user rejects all consent from SDK List. |
onSdkListSdkConsentChanges | Triggered when user opts in / out of an SDK on the SDK List view. |
allSDKViewsDismissed | Triggered when all the OT SDK Views are dismissed from the view hierarchy. |
The allSDKViewsDismissed event is often used because:
- It is the last UI event to fire.
- It only fires once all SDK UIs are dismissed from the view hierarchy.
To set it up
m.global.OTsdk.eventlistener.observeField("onShowBanner", "eventlistener")
m.global.OTsdk.eventlistener.observeField("onHideBanner", "eventlistener")
m.global.OTsdk.eventlistener.observeField("onBannerClickedAcceptAll", "eventlistener")
m.global.OTsdk.eventlistener.observeField("onBannerClickedRejectAll", "eventlistener")
m.global.OTsdk.eventlistener.observeField("onBannerClickedClose", "eventlistener")
m.global.OTsdk.eventlistener.observeField("onShowPreferenceCenter", "eventlistener")
m.global.OTsdk.eventlistener.observeField("onHidePreferenceCenter", "eventlistener")
m.global.OTsdk.eventlistener.observeField("onPreferenceCenterAcceptAll", "eventlistener")
m.global.OTsdk.eventlistener.observeField("onPreferenceCenterRejectAll", "eventlistener")
m.global.OTsdk.eventlistener.observeField("onPreferenceCenterConfirmChoices", "eventlistener")
m.global.OTsdk.eventlistener.observeField("onPreferenceCenterPurposeConsentChanged", "eventlistener")
m.global.OTsdk.eventlistener.observeField("onPreferenceCenterPurposeLegitimateInterestChanged", "eventlistener")
m.global.OTsdk.eventlistener.observeField("onShowVendorList", "eventlistener")
m.global.OTsdk.eventlistener.observeField("onHideVendorList", "eventlistener")
m.global.OTsdk.eventlistener.observeField("onVendorListAcceptAll", "eventlistener")
m.global.OTsdk.eventlistener.observeField("onVendorListRejectAll", "eventlistener")
m.global.OTsdk.eventlistener.observeField("onVendorConfirmChoices", "eventlistener")
m.global.OTsdk.eventlistener.observeField("onVendorListVendorConsentChanged", "eventlistener")
m.global.OTsdk.eventlistener.observeField("onVendorListVendorLegitimateInterestChanged", "eventlistener")
m.global.OTsdk.eventlistener.observeField("onShowSDKList", "eventlistener")
m.global.OTsdk.eventlistener.observeField("onHideSDKList", "eventlistener")
m.global.OTsdk.eventlistener.observeField("onSDKListAcceptAll", "eventlistener")
m.global.OTsdk.eventlistener.observeField("onSDKListRejectAll", "eventlistener")
m.global.OTsdk.eventlistener.observeField("onSDKListConfirmChoices", "eventlistener")
m.global.OTsdk.eventlistener.observeField("onSdkListSdkConsentChanged", "eventlistener")
m.global.OTsdk.eventlistener.observeField("allSDKViewsDismissed", "eventlistener")
m.global.OTsdk.eventlistener.observeField("OTConsentUpdated", "eventlistener")
m.global.OTsdk.eventlistener.observeField("onSwitchUserProfileCallback", "eventlistener")
m.global.OTsdk.eventlistener.observeField("onDeleteProfileCallback", "eventlistener")
m.global.OTsdk.eventlistener.observeField("dataDownloadSucess", "eventlistener")
function eventlistener(data)
data = data.getData()
if type(data) = "roAssociativeArray" and data <> invalid and data.name <> invalid
‘ data.name – event listener name
‘ data.response – data for the event listener
‘ data.success – success data of the event listener
‘ data.error – error data for the event listener
Print data
end if
end function
Updated 4 days ago