The mms_choice_selected_callback() Function

Sourcepoint provides a callback function that fires when a user clicks on a choice button in a message. The callback provides information on the choice selected which is passed as an ID. The callback also provides an opportunity for publishers to do a variety of actions using javascript such as set a cookie on the user for additional targeting, send data to another analytics package or perform some action on the page such as hide a page element.

The framework will pass an integer ID to the choice selected callback:
     1 = Whitelist Instructions Viewed
     2 = Opt-in Recovery
     3 = Alt Ad
     4 = Publisher Custom Choice (iFrame)
     5 = Publisher Custom Choice Redirect
     6 = Continue With Adblocker
     7 = Alt Pay (requires additional agreement with Sourcepoint)
     8 = not used
     9 = Custom JavaScript (enabled by Sourcepoint)
     10 = Welect Video (requires separate agreement with Welect and Sourcepoint)
     11 = Accept All (consent)
     12 = Show Privacy Manager (consent)
     13 = Reject All (consent)
     14 = Samba Video (requires separate agreement with Samba and Sourcepoint)

window._sp_.config.mms_choice_selected_callback = function (choiceID) { 
  console .log( "Choice : id=" + choiceID);
} ;

The code below shows the callback function within the configuration code of the page.

<script type = "text/javascript"> 
( function () {

/* { PUT SP BOOTSTRAP CODE HERE INLINE }*/

/* standard configuration parameters for sourcepoint*/
window._sp_ = window._sp_ || {};
window._sp_.config = window._sp_.config || {};

window._sp_.config.account_id = YOUR_ACCOUNT_ID;
window._sp_.config.content_control_callback = function () { } ;

/* replace with your messaging domain*/
window._sp_.config.mms_domain = 'message.sp-prod.net' ;

/* messaging-specific configuration*/
window._sp_.mms = window._sp_.mms || {};
window._sp_.mms.cmd = window._sp_.mms.cmd || [];

/*CHOICE CALLBACK WRITING CHOICE ID TO CONSOLE*/
window._sp_.config.mms_choice_selected_callback = function (choiceID) {
  console.log( "Choice : id=" + choiceID);
} ;

window._sp_.config.mms_client_data_callback = function (o) {
   console.log("data callback json: " + o);
};

/* example usage of setting a targeting parameter*/
window._sp_.mms.cmd.push( function () {
   window._sp_.mms.setTargeting( "color_preference" , "blue" );
});

// tell the messaging library that all params are set and it can proceed
window._sp_.mms.cmd.push( function () {
   window._sp_.mms.startMsg();
});

/* use the sourcepoint bootstrap code (inlined above) to load
 the main messaging library. Replace 'messaging-2.0.980.js' with
 the location of the file on your server or CDN*/
window._sp_.bootstrap( 'messaging-2.0.980.js' ); })();
</script>


Did this answer your question?