Optional Callbacks

Sourcepoint provides callbacks that you can define as part of its latest version of the messaging code.

<script type="text/javascript">
!function () { var e = function () { var e, t = "__tcfapiLocator", a = [], n = window; for (; n;) { try { if (n.frames[t]) { e = n; break } } catch (e) { } if (n === window.top) break; n = n.parent } e || (!function e() { var a = n.document, r = !!n.frames[t]; if (!r) if (a.body) { var i = a.createElement("iframe"); i.style.cssText = "display:none", i.name = t, a.body.appendChild(i) } else setTimeout(e, 5); return !r }(), n.__tcfapi = function () { for (var e, t = arguments.length, n = new Array(t), r = 0; r < t; r++)n[r] = arguments[r]; if (!n.length) return a; if ("setGdprApplies" === n[0]) n.length > 3 && 2 === parseInt(n[1], 10) && "boolean" == typeof n[3] && (e = n[3], "function" == typeof n[2] && n[2]("set", !0)); else if ("ping" === n[0]) { var i = { gdprApplies: e, cmpLoaded: !1, cmpStatus: "stub" }; "function" == typeof n[2] && n[2](i) } else a.push(n) }, n.addEventListener("message", (function (e) { var t = "string" == typeof e.data, a = {}; try { a = t ? JSON.parse(e.data) : e.data } catch (e) { } var n = a.__tcfapiCall; n && window.__tcfapi(n.command, n.version, (function (a, r) { var i = { __tcfapiReturn: { returnValue: a, success: r, callId: n.callId } }; t && (i = JSON.stringify(i)), e.source.postMessage(i, "*") }), n.parameter) }), !1)) }; "undefined" != typeof module ? module.exports = e : e() }();
</script>
<script>
window._sp_ = {
config: {
accountId: ACCOUNT_ID_HERE,
baseEndpoint: 'https://cdn.privacy-mgmt.com',
events: {
onMessageReady: function () {
console.log('onMessageReady')
},
onMessageChoiceSelect: function (choice_id, choice_type_id) {
console.log('onMessageChoiceSelect choice_id: ', choice_id);
console.log('onMessageChoiceSelect choice_id: ', choice_type_id);
},
onPrivacyManagerAction: function (pmData) {
console.log('onPrivacyManagerAction', pmData)
},
onMessageChoiceError: function (err) {
console.log('onMessageChoiceError', err)
},
onConsentReady: function (consentUUID, euconsent) {
console.log('onConsentReady')
console.log('consentUUID', consentUUID)
console.log('euconsent', euconsent)
},
onPMCancel: function () {
console.log('onPMCancel')
},
onMessageReceiveData: function (data) {
console.log('onMessageReceiveData', data)
console.log(JSON.stringify(data));
},
onSPPMObjectReady: function () {
console.log('onSPPMObjectReady')
}
},
targetingParams: {
test: 1
}
}
}
</script>
<script src="https://cdn.privacy-mgmt.com/messagingWithoutDetection.js"></script>

The callbacks available are:

  • onMessageReady - this event fires when a message is about to display.

  • onMessageChoiceSelect - this event fires when a call-to-action button in a message has been clicked. The receives two integers. The first is the choice_id and it represents the id value of the choice selected that is specific to that choice. The second is the choice_type_id which is the ID of the type of choice clicked. A table of the choice type IDs is below.

  • onPrivacyManagerAction - this event fires when a button in a privacy manager has been clicked on. The possible values for the string returned to the function are "SAVE_AND_EXIT" and "CANCEL".

  • onMessageChoiceError - this event fires when there was an error in the message delivery process. A brief description of the error is returned.

  • onConsentReady - this event fires when the consent object is ready. The consentUUID and euconsent values are sent to the callback.

  • onPMCancel - this event fires when a user hits the cancel button of the privacy manager.

  • onMessageReceiveData - this 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 in in the following structure: { "message_url":"https://notice.sp-prod.net?message_id=12345", "msg_id":"12345", "prtn_uuid":"6e769cbb-0adc-4ac2-b91c", "msg_desc":"Consent Message 9.20.2019", "cmpgn_id":"39599", "bucket":"49", "uuid":"fa3db7d9-3258-46f1-8386-97ce2b4a5249" }

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

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