Track user contribution in adservers and DMPs

In order to track  revenue contributions made by whitelisted users in an ad server, we recommend sending and reporting on key-value pairs in the ad server. In this article, we will provide examples for how to configure your Sourcepoint implementation and your ad server platform to track user contributions in the ad server.  


Sourcepoint configuration

Send a key-value pair to the ad server as a targeting parameter by utilizing Sourcepoint's client data callback function (sp_setCookie) to set a cookie. This cookie will be retrieved on subsequent pageviews.

  Note: The cookie setter function sp_setCookie can be replaced with your site’s cookie setter function. Alternatively, your organization might leverage jQuery's $.cookie() to achieve the same result.

window._sp_.config.mms_client_data_callback = function(o) {
   var _sp_msg_id = parseInt(o.info.msg_id);
   var _sp_cookie_val = "";
   if(o.d.abp==true && _sp_msg_id>0){
      sp_setCookie("sp","whitelist",365);
   }
};function sp_setCookie(cname, cvalue, exdays) {
   var d = new Date();
   d.setTime(d.getTime() + (exdays*24*60*60*1000));
   var expires = "expires="+ d.toUTCString();
   document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
}

In order to send data to your property's analytics platform, your organization will also need to leverage Sourcepoint's mms_client_data_callback function.

window ._sp_.config.mms_client_data_callback = function (data) {
	// do something useful with the dataObject
	var ab_state = data.d.abp;
	var campaign_id = data.info.cmpgn_id;
	var message_id = data.info.msg_id;	//Send data to external platform
}; window ._sp_.config.mms_choice_selected_callback = function (choiceID) {
	var choice_made =choiceID;
	//Send data to external platform
};

Ad server configuation

In the example below, we are using key-value pair capabilities of Google DFP. The code below will retrieve the sp cookie using the sp_getCookie function. Your property can and will most likely use its own cookie retrieval function.

Once the cookie value is stored in a JavaScript variable it can be passed to the ad server using the ad server’s standard key-value pair targeting functionality.

In this example, we are showing Google DFP’s googletag.pubads().setTargeting() call. This enables reporting and targeting in the DFP adserving platform.

<script>
function sp_getCookie(cname) {
   var name = cname + "=";
   var decodedCookie = decodeURIComponent(document.cookie);
   var ca = decodedCookie.split(';');
   for(var i = 0; i <ca.length; i++) {
      var c = ca[i];
      while (c.charAt(0) == ' ') {
         c = c.substring(1);
      }
      if (c.indexOf(name) == 0) {
         return c.substring(name.length, c.length);
      }
   }
   return "";
}var sp_cookie_val = "";
   sp_cookie_val = sp_getCookie(cname);   googletag.cmd.push(function() {
      googletag.defineSlot("/1234/travel/asia", [728, 90], "div-gpt            ad-123456789-0")
         .addService(googletag.pubads())
         .setTargeting("interests", ["sports", "music", "movies"]);
   googletag.pubads().setTargeting("topic","basketball");
   googletag.pubads().setTargeting("sp",sp_cookie_val);
   googletag.pubads().enableSingleRequest();
   googletag.enableServices();
});
</script>

  Note: Ad servers may require you to whitelist the key-value pair before it is available for reporting in the ad server. 

test.jpg

Was this article helpful?
0 out of 0 found this helpful