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

Optional callbacks

  Note: Every optional callback in the table below (except onSPPMObjectReady) receives a message type (i.e. gdpr, ccpa, adblock) as the first argument to differentiate between events that may be implemented on the property.

Callback Description

Event fires when a message is about to display.


Event fires when a call-to-action button in a message has been clicked.

The callback receives three arguments:

  • the message type to which the choice belongs (i.e. gdpr, ccpa, adblock). This argument is always passed first.
  • choice_id and it represents the id value of the choice selected and is specific to that choice.
  • choice_type_id which is the ID of the type of choice clicked. Click here for more information on the choice_type_id.

Event fires when a button in a privacy manager has been clicked. The possible values for the string returned to the function are:

onMessageChoiceError Event fires when there was an error in the message delivery process. A brief description of the error is returned.

Event fires when the consent object is ready. The consentUUID and euconsent values are sent to the callback.

  Note: This does not apply to the TCF consent string. You should use the addEventListener command of the __tcfapi function and listen for the tcloaded event to obtain the user's consent string as soon as it available. More information can be found here.

onPMCancel Event fires when a user hits the cancel button of the privacy manager.

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

Data Description
prtnUUID The partition UUID. Used to keep the end-user in the partition bucket that they originally landed in. 
messageId The ID for the message.
msgDescription The name of the message in your Sourcepoint portal.
bucket The specific partition bucket (0-999).
uuid The end-user's unique ID for the legislation type.
categoryId The legislation regime for the message.
subcategoryId The type of message.

Event fires when the privacy manager is ready to be displayed on the page. It can be used to notify on-page functions that the privacy manager is now available to be displayed using the Sourcepoint plug and play JavaScript code.

  Note: Does not receive a message as an argument.


Event fires when there is an error. The callback function is passed three parameters.

  • An error code (string) - the error code corresponds to one of five string values defined in the this table.
  • An error object (object) - the JavaScript error object including the associated stack trace.
  • A user reset value (boolean) - whether the user ID was reset for this individual.
    window._sp_queue = [];
    window._sp_ = {
        config: {
            accountId: ACCOUNT_ID,
            baseEndpoint: '',
            ccpa: { },
            gdpr: { },
            propertyHref: '',
            events: {
              onMessageReady: function (message_type) {
                  console.log('onMessageReady', message_type)
              onMessageChoiceSelect: function (message_type, choice_id, choice_type_id) {
                  console.log('onMessageChoiceSelect message_type: ', message_type);
                  console.log('onMessageChoiceSelect choice_id: ', choice_id);
                  console.log('onMessageChoiceSelect choice_type_id: ', choice_type_id);
              onPrivacyManagerAction: function (message_type, pmData) {
                  console.log('onPrivacyManagerAction message_type:', message_type);
                  console.log('onPrivacyManagerAction', pmData)
              onMessageChoiceError: function (message_type, err) {
                  console.log('onMessageChoiceError', message_type);
                  console.log('onMessageChoiceError', err)
              onConsentReady: function (message_type, consentUUID, euconsent) {
                  console.log('onConsentReady', 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('onMessageReceiveData', message_type);
                  console.log('onMessageReceiveData', data)
              onSPPMObjectReady: function () {
              onError: function (message_type, errorCode, errorObject, userReset){
                  console.log('errorCode: ', message_type);
                  console.log('errorCode: ' + errorCode);
                  console.log('userReset: ' + userReset);

Choice type ID descriptions

The choice type ID denotes the action made by an end user, 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:

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

The user has chosen to view instructions on how to whitelist a site.


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


The user has chosen to view a directly sold video instead of disabling adblockers (requires a separate agreement).


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


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


The user has chosen to continue with adblockers enabled.


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


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


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


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


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


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


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

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 anyway 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

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.


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