roshanoracle
5/24/2018 - 1:37 PM

BlueKai CoreTag : Empty Var & Array Handler

Adds additional function to handle arrays and empty vars

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

	// ALLOW MULTIPLE CALLS/SINGLE PAGE APPS
	bk_allow_multiple_calls=true; bk_use_multiple_iframes=true ;

	// FUNCTION : Type Checker
	function toType(obj) {
		return ({}).toString.call(obj).match(/\s([a-zA-Z]+)/)[1].toLowerCase();
	}	

	// FUNCTION : Send Data
	var sendPhint = function(varName,varValue){

		if (toType(varValue) === "string" && varValue){
			bk_addPageCtx(varName, varValue); // example phint (change to your own useful variabes)
		} else if(toType(varValue) === "array"){
			bk_addPageCtx(varName,"," + varValue.join(",") + ","); // example phint (change to your own useful variabes)
		}
	}

	// SEND DATA
	sendPhint("page_name","page_name");
	sendPhint("page_type",["array","of","data"]);
	sendPhint("nothing","");


	// <optional> Email Address (this will be MD5 and SHA-256 hashed)
	bk_addEmailHash('ENTER EMAIL');

	// Send Data 
	BKTAG.doTag(CONTAINER_ID, 4);  // change "ENTER CONTAINER ID HERE" to the container ID/Site ID you want to use
};
(function() {
  var scripts = document.getElementsByTagName('script')[0];
  var s = document.createElement('script');
  s.async = true;
  s.src = "//tags.bkrtx.com/js/bk-coretag.js";
  scripts.parentNode.insertBefore(s, scripts);
}());
</script>