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 Description
message_type An enum value, which category the message belongs: gdpr, 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 Description
message_type An enum value, which category the message belongs: gdpr, ccpa, ios14, custom
choice_id The id of the button the end-user clicked on
choice_type_id The id for the action the end-user has clicked on. Click here for more information on the choice_type_id
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 Description
message_type An enum value, which category the message belongs: gdpr, ccpa, ios14, custom
pmData object Privacy manager object contains an overview of end-user consent for purposes and vendors. See table below.
pmData parameter Description
purposeConsent An enum value, indicates if the end-user has accepted all, some or none of the purposes
vendorConsent An enum value, 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)); }

onMessageChoiceError

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

Parameter Description
message_type An enum value, which category the message belongs: gdpr, 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 Description
message_type An enum value, which category the message belongs: gdpr, ccpa, ios14, custom
consentUUID The id of the end-user's consent profile.
euconsent The TC string for the end-user.
onConsentReady: function (message_type, consentUUID, euconsent) {
   console.log('message_type: ' + message_type);
   console.log('consentUUID: ' + consentUUID)
   console.log('euconsent: ' + euconsent)
}

onPMCancel

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

Parameter Description
message_type An enum value, which category the message belongs: gdpr, 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 Description
message_type An enum value, which category the message belongs: gdpr, ccpa, ios14, custom
messageId The message ID.
msgDescription Name of message in your Sourcepoint portal.
bucket The specific partition bucket (0-999).
uuid End-user's consent profile ID.
categoryId The category ID for the message. Click here for description.
subcategoryId The message type ID. Click here for description.

categoryID

Description
1 gdpr
2 ccpa
4 ios
5 custom

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 Description
message_type An enum value, which category the message belongs: gdpr, ccpa, ios14, custom
errorCode The error code corresponds to one of five string values defined in this table
errorObject 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);
}
...
<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) { console.log('message_type: ' + message_type); console.log('consentUUID: ' + consentUUID) console.log('euconsent: ' + euconsent) }, 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> ...

Choice type ID descriptions

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 view instructions on how to whitelist a site.

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.

onError code definitions

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.

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.

Was this article helpful?
0 out of 0 found this helpful