onError Callback


Sourcepoint has introduced a new error handling callback function called onError. The callback function is passed three parameters.

  • An error code (string) - the error code corresponds to one of five string values defined in the next section of this document.

  • 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.

Error Code Definitions

The list of error codes passed to the function are below:

  • ACTION - The error came from an Action like a Custom Consent Action.

  • CHOICE - An error coming from an invalid choice action being provided to the script.

  • CMP_CALLBACK - An error thrown by the __tcfapi callback.

  • REQUEST - An error in the request sent to the Sourcepoint platform (i.e. a network error). In this case the user ID of the individual will be reset.

  • UNKNOWN - A generic unknown error occurred. In this case the user ID of the individual will be reset.

As noted above, the user ID of the site visitor will be reset when a REQUEST or an UNKNOWN error type occurs.

Example Code

Below is an example of a callback configured to write the errorCode, errorObject and userReset value to the developer console.

<script type="text/javascript">
//Stub function omitted for brevity
window._sp_ = {
config: {
accountId: ACCOUNT_ID,
wrapperAPIOrigin: "",
baseEndpoint: "",
events: {
onError: function (errorCode, errorObject, userReset){
console.log('errorCode: ' + errorCode);
console.log('userReset: ' + userReset);
<script src="">