Optional Event Callbacks
Sourcepoint provides callbacks that you can define within the messaging code. Please refer to the table below for more information

Optional Callbacks

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
onMessageReady
Event fires when a message is about to display.
onMessageChoiceSelect
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 .
onPrivacyManagerAction
Event fires when a button in a privacy manager has been clicked. The possible values for the string returned to the function are:
SAVE_AND_EXIT
CANCEL
onMessageChoiceError
Event fires when there was an error in the message delivery process. A brief description of the error is returned.
onConsentReady
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.
onMessageReceiveData
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:
  • printUUID: 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 type for the message.
  • subcategoryId: The type of message.
onSPPMObjectReady
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.
onError
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.
1
//Example.
2
...
3
<script>
4
window._sp_queue = [];
5
window._sp_ = {
6
config: {
7
accountId: ACCOUNT_ID,
8
baseEndpoint: 'https://cdn.privacy-mgmt.com',
9
ccpa: { },
10
gdpr: { },
11
propertyHref: 'https://yourexamplehere.com',
12
events: {
13
onMessageReady: function (message_type) {
14
console.log('onMessageReady', message_type)
15
},
16
onMessageChoiceSelect: function (message_type, choice_id, choice_type_id) {
17
console.log('onMessageChoiceSelect message_type: ', message_type);
18
console.log('onMessageChoiceSelect choice_id: ', choice_id);
19
console.log('onMessageChoiceSelect choice_type_id: ', choice_type_id);
20
},
21
onPrivacyManagerAction: function (message_type, pmData) {
22
console.log('onPrivacyManagerAction message_type:', message_type);
23
console.log('onPrivacyManagerAction', pmData)
24
},
25
onMessageChoiceError: function (message_type, err) {
26
console.log('onMessageChoiceError', message_type);
27
console.log('onMessageChoiceError', err)
28
},
29
onConsentReady: function (message_type, consentUUID, euconsent) {
30
console.log('onConsentReady', message_type);
31
console.log('consentUUID', consentUUID)
32
console.log('euconsent', euconsent)
33
},
34
onPMCancel: function (message_type) {
35
console.log('onPMCancel', message_type)
36
},
37
onMessageReceiveData: function (message_type, data) {
38
console.log('onMessageReceiveData', message_type);
39
console.log('onMessageReceiveData', data)
40
console.log(JSON.stringify(data));
41
},
42
onSPPMObjectReady: function () {
43
console.log('onSPPMObjectReady')
44
},
45
onError: function (message_type, errorCode, errorObject, userReset){
46
console.log('errorCode: ', message_type);
47
console.log('errorCode: ' + errorCode);
48
console.log(errorObject);
49
console.log('userReset: ' + userReset);
50
},
51
}
52
}
53
}
54
</script>
55
...
Copied!

Choice Type ID Descriptions

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 (no longer used)
3
The user has chosen to view a directly sold video instead of disabling adblockers (requires a separate agreement)
4
The user has chosen to view custom content in an iframe
5
The user has chosen a option to redirect to another page
6
The user has chosen to continue with adblockers enabled
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 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
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.
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.
Last modified 23d ago