Optional Features

Leveraging Key-Value Pairs Using setTargeting(key, value)

The setTargeting(key, value) function will add a Key-Value pair to the messaging call for the purposes of decisioning in the messaging scenario. Multiple key-value pairs can be added per messaging call. In order for the value to be sent, this call must come before the startMsg() function is called.

If we look at the example above for a typical Dialogue implementation we see the code below. The setTargeting(key,value) function being used here enables you to send data to Sourcepoint to be used in a scenario as targeting criteria. In this example, the profile we are sending is meant to convey the color_preference of blue for the user. This information could be data that is stored in the site DMP and passed as JavaScript string to Dialogue.

Key-Value Pair Code Example:

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

To leverage this data, there would be a corresponding step in the Dialogue user interface that would perform (or not perform) an action based on the value portion of the key-value pair being sent. In the example screenshot below, the scenario is setup to show a message only if there is  value of blue being sent for the color_preference key.

Key-Value Pair User Interface Setup Example

The value portion of the key-value pair can be sent as a JavaScript variable. The example below shows the  variable dmp_color being set outside the setTargeting function and that variable being used as the value portion of the key-value pair. The same UI setup from the previous example could apply.

Key-Value Pair Code with Variable Example

var dmp_color = "blue";

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

Sourcepoint can match either using “match” logic or “contains” logic. The previous user interface example showed using “match” logic. However, in some instances you may need to use “contains” logic. For example if the data being sent from the external DMP is a comma separated list. 

In the example below, the dmp_colors variable contains a comma separated list of color values (red, blue and green). If we want to show messages to users that have blue as a color preference, but also may have other color preferences too, we can do this by sending the values to Dialogue using the dmp_colors variable and then leverage the contains logic in the UI.

Key-Value Pair Code with Comma Separated Values

var dmp_colors = "red,blue,green";

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

Using Data Callbacks

Sourcepoint provides callback functions at two specific events in the message process. These callbacks can be used to set custom cookie values for later key-value pair targeting, send data to website analytics platforms for deeper analysis, send data to DMPs for custom targeting, etc.

The mms_client_data_callback() Function

The first callback, mms_client_data_callback, is triggered when the Dialogue server responds and determines whether or not a message should be served to the user.  The callback each time a call to startMsg() is called regardless of whether a message is shown or not. The example function below prints the callback’s JSON to the developer console window.

Example mms_cleint_data_callback Function

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

The JSON data sent to the function provides data on some key aspects of the message being displayed.

Presence of an adblocker

  • Message ID of the message shown to the web visitor this pageview (0 if no message is shown)

  • Unique Identifier of partition or A/B test group that visitor is in

  • The campaign ID currently running for this site

  • If the user has previously clicked on any choice options

Below is the structure of JSON data sent to the callback and a table of definitions for each of the value within the JSON.

Example mms_cleint_data_callback JSON Data

     "abp":true ,
     "wl":false ,
     "bucket" :  667
     "msg_desc":"All options"

JSON Data Definitions

  • d.abp - A value of true if adblocker present, false otherwise

  • d.abt - No longer used.

  • o.wl - Whether the user clicked on the button to show the whitelist instructions or not. This is NOT whether a user actually whitelisted. It only measures whether the user engaged with the whitelist instructions button or not.

  • o.oir - The user has opted-in to recovery in the past

  • u.uuid - Sourcepoint assigned UUID for the user (randomly assigned when first see user)

  • u.bucket - Sourcepoint assigned partition bucket (randomly assigned when first see user)

  • info.cmpgn_id - The campaign ID of the campaign currently running.

  • info.prtn_uuid - The id value associated with the partition the user belongs to. Partitions are determined in the Dialogue UI by assigning a group of bucket values to a partition.

  • info.msg_id - The ID value of the message shown (or 0 if no message this call)

  • info.msg_desc - The text description of message entered into the Dialogue UI.

The mms_choice_selected_callback() Function

The Choice Selected Callback is fired when a user selects a choice in a message. The callback provides information on the choice selected and also provides the opportunity for publishers to set a cookie on the user for additional targeting or leveraged as key-value pairs in an adserver.

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

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


If the publisher subscribes to the Sourcepoint Consent Management Platform (CMP) and needs to capture consent for DFP, we have built that capability into the Sourcepoint CMP. At this point in time, Google DFP has enabled the ability to serve non-personalized ads through a flag set in a publisher’s GPT code.  Please read the the article entitled “Ads personalization settings in Google’s publisher ad tags” for more information.

The first step in the process is adding DoubleClick to the vendor list in the Sourcepoint UI (see screenshot below).

When a user is displayed a consent request and opts-in to DFP, the Consent Management Platform will set the following cookie value on the publisher’s first-party cookie


This cookie value can then be read back using JavaScript by the publisher on that or subsequent pageviews. The publisher takes that value and sends either a 0 or 1 to DFP based on the users choice using googletag.pubads().setRequestNonPersonalizedAds(1) or googletag.pubads().setRequestNonPersonalizedAds(0).

Did this answer your question?