Sourcepoint provides callbacks that you can define within the messaging code. Please refer to the tables below for more information


Optional callbacks

The following nine callbacks can be utilized by your organization to include custom code to be executed in response to keys events, for example when an end-user clicks on a specific button.

Some of the event callbacks return data that can be used to react to events. A description of the event callback and data returned is described below.

onMessageReady

Event callback fires when a message is about to display. This callback returns the message_type:

Parameter Type Description
message_type String The category to which the message belongs: gdpr, usnat, ccpa, ios14, custom
onMessageReady: function (message_type) {
   console.log('message_type: ' + message_type)
}

onMessageChoiceSelect

Event callback fires when a call-to-action button in a message has been clicked. This callback returns message_type, choice_id and choice_type_id:

Parameter Type Description
message_type String The category to which the message belongs: gdpr, usnat, ccpa, ios14, custom
choice_id Number The id of the button the end-user clicked on
choice_type_id Number The id for the action the end-user has clicked on. See below for more information on the choice_type_id

The choice type ID denotes the action made by an end user and is a value returned by the onMessageChoiceSelect callback event.

 The choice type id also applies to the API calls to the Sourcepoint servers for each end-user action on a first layer or privacy manager. In the browser display console you will see this API POST call:

POST https://cdn.privacy-mgmt.com/wrapper/v2/messages/choice/gdpr/{CHOICE_TYPE_ID}?requestUUID={REQUEST_UUID}&hasCsp=true&env={ENVIRONMENT}
Parameter Description
{CHOICE_TYPE_ID} The id of action made by the end-user. See table below
{REQUEST_UUID} The request UUID for the end-user
{ENVIRONMENT} The campaign environment, enum value for live (prod) or stage (stage)
Choice Type ID Description
1

The user has chosen to "continue without agreeing" (i.e. reject all purposes whose legal basis is user consent while allowing purposes whose legal basis is legitimate interest)

2

The user has chosen to opt into ad recovery (Legacy).

4

The user has chosen to view custom content in an iframe.

5

The user has chosen an option to redirect to another page.

7

The user has chosen a micropayment option (requires a separate agreement).

9

The user has selected an option tied to custom JavaScript on the site page.

10

The user has chosen to view a video provided by Welect (requires a separate agreement).

11

The user has chosen the "Accept All" option in a consent message.

12

The user has chosen to view a privacy manager (consent preferences) UI.

13

The user has chosen the "Reject All" message from a consent message.

14

Samba Video (requires separate agreement with Samba and Sourcepoint).

15 Dismiss button.
onMessageChoiceSelect: function (message_type, choice_id, choice_type_id) {
   console.log('message_type: ' + message_type);
   console.log('choice_id: ' + choice_id);
   console.log('choice_type_id: ' + choice_type_id);
}

onPrivacyManagerAction

Event callback fires when a privacy manager button has been clicked. This callback returns message_type and the pmData object:

Parameter Type Description
message_type String The category to which the message belongs: gdpr, usnat, ccpa, ios14, custom
pmData Object Privacy manager object contains an overview of end-user consent for purposes and vendors. See table below.
pmData object
Property Type Description
purposeConsent String Indicates if the end-user has accepted all, some or none of the purposes
vendorConsent String Indicates if the end-user has accepted all, some or none of the vendors
onPrivacyManagerAction: function (message_type, pmData) {
   console.log('message_type: ' + message_type);
console.log('purposeConsent: ' + pmData.purposeConsent);
console.log('vendorConsent: ' + pmData.vendorConsent);
console.log(JSON.stringify(pmData)); }

onPrivacyManagerActionStatus

Event callback fires after an privacy manager button has been clicked and after network calls have finished. This callback returns message_type, status, and actionType.

Property Type Description
message_type String The category to which the message belongs: gdpr, usnat, and ccpa.
status String Indicates if the end-user has accepted all, some or none of the purposes/privacy choices.
actionType Number The id for the action the end-user has clicked on. See choice_type_id for more information.
onPrivacyManagerActionStatus: function(message_type, status, actionType) {
    console.log('message_type: ' + message_type);
    console.log('status: ' + status);
    console.log('actionType: ' + actionType);
}

onMessageChoiceError

Event callback fires when there is an error in the message delivery process. This callback returns the message_type and err:

Parameter Type Description
message_type String The category to which the message belongs: gdpr, usnat, ccpa, ios14, custom
err    
onMessageChoiceError: function (message_type, err) {
   console.log('onMessageChoiceError' + message_type);
   console.log('onMessageChoiceError' + err)
}

onConsentReady

Event callback fires when the consent object is ready. This callback returns the message_type, consentUUID and euconsent:

Parameter Type Description
message_type String An enum value, which category the message belongs: gdpr, usnat, ccpa, ios14, custom
consentUUID String The id of the end-user's consent profile.
euconsent String The TC string for the end-user.
info Object Click here for more information on the properties contained in the info object. 
info object
Property Type Value
addtlConsent String Google Additional Consent allows Google and the IAB Framework to pass end-user consent to Google Ad Technology Providers despite not adhering to the IAB TCF v2 Framework.
applies Boolean The end-user is identified as being in the geographic area defined in the vendor list and for which Sourcepoint will generate a consent string for the legislation.
consentedToAll Boolean The end-user has consented to all purposes and vendors.
onConsentReady: function (message_type, consentUUID, euconsent) {
   console.log('message_type: ' + message_type);
   console.log('consentUUID: ' + consentUUID);
   console.log('euconsent: ' + euconsent);
   console.log(info);
}

onPMCancel

Event callback fires when a user clicks the privacy manager's cancel button. This callback returns the message_type:

Parameter Type Description
message_type String The category to which the message belongs: gdpr, usnat, ccpa, ios14, custom
onPMCancel: function (message_type) {
   console.log('message_type: ' + message_type)
}

onMessageReceiveData

Event fires when a message is displayed to the user and sends data about the message and campaign to the callback. The callback data returns the following information:

Parameter Type Description
message_type String The category to which the message belongs: gdpr, usnat, ccpa, ios14, custom
data Object Click here for more information on the properties contained in the data object. 
data object
Property Type Description
messageId Number The message ID.
msgDescription String Name of message in your Sourcepoint portal.
bucket Number The specific partition bucket (0-999).
uuid String End-user's consent profile ID.
categoryId Number The category ID for the message. Click here for description.
subcategoryId Number The message type ID. Click here for description.

categoryID

Description
1 gdpr
2 ccpa
4 ios
5 custom
6 usnat

subcategoryId

Description
1 notice
2 privacy_manager
3 subject_access_request
4 dsar
5 notice-tcf-v2
6 notice-native
7 privacy_manager_ott
8 notice_non_iab
9 privacy_manager_non_iab
10 ios
11 ccpa_ott
12 ccpa_pm
13 custom
14 native-ott
onMessageReceiveData: function (message_type, data) {
   console.log('message_type' + message_type);
   console.log('prtnUUID: ' + data.prtnUUID);
console.log('messageId: ' + data.messageId);
console.log('messageDescription: ' + data.messageDescription);
console.log('bucket: ' + data.bucket);
console.log('categoryId: ' + data.categoryId);
console.log('subCategoryId: ' + data.subCategoryId); console.log(JSON.stringify(data)); }

onSPPMObjectReady

Event callback fires when the privacy manager is ready to be displayed on the page.

onSPPMObjectReady: function () {
   console.log('onSPPMObjectReady')
}

onError

Event callback fires when an error occurs. This callback function returns message_type, errorCode and errorObject:

Parameter Type Description
message_type String The category to which the message belongs: gdpr, usnat, ccpa, ios14, custom
errorCode String The error code corresponds to one of five string values defined in this table
error Object This object includes the error stack trace.
onError: function (message_type, errorCode, errorObject, userReset){
   console.log('message_type: ' + message_type);
   console.log('errorCode: ' + errorCode);
   console.log(errorObject);
   console.log('userReset: ' + userReset);
}

The list of error codes passed that can be passed to the onError callback are:

onError code Description Troubleshoot
ACTION

Error came from an action. Some possible actions that can cause this error are:

  • JavaScript snippets executed by Sourcepoint
  • JavaScript snippets executed by the client (i.e. custom consent or custom reject actions in the vendor list)

Identify JavaScript added as a custom consent action and/or custom reject action in your vendor list and run the actions in your developer console.

  Note: This JavaScript is not manipulated in any way and needs to be cross-browser compliant.

CHOICE Error came from an invalid choice action (e.g. accept, reject, etc...) being provided to the script.

Error could be due to a malformed message.

Try updating the button or link that triggers this error to fix the choice action, or re-save the message.

CMP_CALLBACK Error thrown by the __tcfapi or _sp_ callback function. Examine the stack trace in the error provided to identify the problem in the callback function being passed to the __tcfapi or _sp_ function
REQUEST

A network error occurred. Some possible reasons that can cause this error are:

  • connectivity issues
  • content blockers
  • server-side error

  Note: In this case the user ID of the individual will be reset.

Generally, these errors are not fixable but should be rare.

RENDERING_APP_PM

Our message renderer has encountered an error while rendering a Privacy Manager message and may be in a bad state. The script will not display the message.

If this error occurs please contact your Sourcepoint key account manager.

RENDERING_APP_MESSAGE

Our message renderer has encountered an error while rendering a message and may be in a bad state. The script will not display the message.

If this error occurs please contact your Sourcepoint key account manager.

RENDERING_APP_SIGNATURE

For preloaded messages, our message renderer encountered an error while trying to validate your message's cryptographic signature.

If this error occurs please contact your Sourcepoint key account manager.

UNKNOWN

Unclassified error occurred.

  Note: In this case the user ID of the individual will be reset.

Examine the stack trace in the error provided. If the error persists and is not identifiable, please contact your Sourcepoint representative.


Example

...
<script>
    window._sp_queue = [];
    window._sp_ = {
        config: {
            accountId: ACCOUNT_ID,
            baseEndpoint: 'https://cdn.privacy-mgmt.com',
            ccpa: { },
            gdpr: { },
            propertyHref: 'https://yourexamplehere.com',
            events: {
              onMessageReady: function (message_type) {
                  console.log('onMessageReady' + message_type)
              },
              onMessageChoiceSelect: function (message_type, choice_id, choice_type_id) {
                  console.log('message_type: ' + message_type);
                  console.log('choice_id: ' + choice_id);
                  console.log('choice_type_id: ' + choice_type_id);
              },
              onPrivacyManagerAction: function (message_type, pmData) {
                  console.log('message_type:' + message_type);
                  console.log('purposeConsent: ' + pmData.purposeConsent);
console.log('vendorConsent: ' + pmData.vendorConsent);
console.log(JSON.stringify(pmData)); }, onMessageChoiceError: function (message_type, err) { console.log('message_type: ' + message_type); console.log('error: ' + err) }, onConsentReady: function (message_type, consentUUID, euconsent, info) { console.log('message_type: ' + message_type); console.log('consentUUID: ' + consentUUID); console.log('euconsent: ' + euconsent); console.log(info); }, onPMCancel: function (message_type) { console.log('onPMCancel' + message_type) }, onMessageReceiveData: function (message_type, data) { console.log('message_type: ' + message_type); console.log('prtnUUID: ' + data.prtnUUID);
console.log('messageId: ' + data.messageId);
console.log('messageDescription: ' + data.messageDescription);
console.log('bucket: ' + data.bucket);
console.log('categoryId: ' + data.categoryId);
console.log('subCategoryId: ' + data.subCategoryId); console.log(JSON.stringify(data)); }, onSPPMObjectReady: function () { console.log('onSPPMObjectReady') }, onError: function (message_type, errorCode, errorObject, userReset){ console.log('message_type: ' + message_type); console.log('errorCode: ' + errorCode); console.log(errorObject); console.log('userReset: ' + userReset); } } } } </script> ...
Was this article helpful?
0 out of 1 found this helpful

Comments

0 comments

Article is closed for comments.