roshanoracle
5/15/2020 - 10:56 AM

DMP CleverTag

Tag with more advanced and simpler configuration options for the client

<!-- THE INITIAL PAGE LOAD TAG MUST HAVE FIRED BEFORE YOU FIRE THIS TAG -->

<!-- Begin BlueKai Tag -->
<script type="text/javascript">

// CONFIGURATION : Amend as required
_bk.conf.container_id = 123456; // Change to container ID (as per BKTAG.doTag(123456, 4);)
_bk.conf.auction_limit = 4; // Set auction limit (as per (as per BKTAG.doTag(123456, 4);))

// PHINTS : Optional Phints to send (name must only use azAZ_09 chars)
bk_addPageCtx('event_name', "NAME OF EVENT");
bk_addPageCtx('any_additional_vars', "send more vars");


// ADVANCED : DO NOT EDIT - BELOW THIS LILNE

// Run functions
_bk.f.block_all_meta();
_bk.f.multi_call();
_bk.f.send_multi_url_path();
_bk.f.declare_query_string_params();
_bk.f.strip_query_string_params();

// Send Data 
BKTAG.doTag(_bk.conf.container_id, _bk.conf.auction_limit);
</script>
<!-- End BlueKai Tag -->
<!-- Begin BlueKai Tag -->
<script type="text/javascript">
window.bk_async = function() {

	window._bk = window._bk || {};
	window._bk.conf = window._bk.conf || {};		
	window._bk.f = window._bk.f = {};

	// CONFIGURATION
	_bk.conf.container_id = 123456; // Change to container ID (as per BKTAG.doTag(123456, 4);)
	_bk.conf.auction_limit = 4; // Set auction limit (as per (as per BKTAG.doTag(123456, 4);))

	// ADVANCED CONFIG : Usually leave as default
	_bk.conf.multi_call = true; // Set to false if you do not want to allow additional DMP calls to be made (e.g. events)	
	_bk.conf.declare_query_string_params = true; // Set to true if you query-string params to be declared as phints
	_bk.conf.strip_query_string_params = false; // Set to true to strip query-string params on URL and Referrer data	
	_bk.conf.block_all_meta  = false; // Set to true to stop URLs/referrer/query-string params being sent completely
	_bk.conf.send_multi_url_path = false; // Sends URL and pathname multiple times to allow better parsing in DMP

	// PHINTS : Optional Phints to send (name must only use azAZ_09 chars)
	bk_addPageCtx('page_name', "my page");
	bk_addPageCtx('any_additional_vars', "send more vars");

	// ADVANCED : DO NOT EDIT - BELOW THIS LILNE
	window._bk.conf.v = "1.0";

	// PLUG-IN : Multi-Call
	_bk.f.multi_call = function(){		
		bk_allow_multiple_calls = _bk.conf.multi_call;
		bk_use_multiple_iframes = _bk.conf.multi_call;
	}

	// PLUG-IN : Meta Blocker
	_bk.f.block_all_meta = function() {
		if (_bk.conf.block_all_meta === true) {
			window.bk_ignore_meta = true;
		} else {
			window.bk_ignore_meta = false;
		};
	}

	// PLUG-IN : Send multi-URLs/Pathnames
	_bk.f.send_multi_url_path = function() {

		if (_bk.conf.send_multi_url_path && !_bk.conf.strip_query_string_params && !_bk.conf.block_all_meta) {
			bk_addPageCtx('ex_url', document.location.href);
			bk_addPageCtx('ex_path', document.location.pathname);
			bk_addPageCtx('ex_path2', document.location.pathname);
		}
	}

	// PLUG-IN : Query-String Declarer
	_bk.f.declare_query_string_params = function() {
		if (_bk.conf.declare_query_string_params && !_bk.conf.block_all_meta && !_bk.conf.strip_query_string_params) {
			var urlParams;
			var match,
				pl = /\+/g, // Regex for replacing addition symbol with a space
				search = /([^&=]+)=?([^&]*)/g,
				decode = function(s) {
					return decodeURIComponent(s.replace(pl, " "));
				},
				query = (window.location.href.split('?')[1]) ? window.location.href.split('?')[1] : "";

			urlParams = {};
			while (match = search.exec(query))
				urlParams[decode(match[1])] = decode(match[2]);

			for (varName in urlParams) {

				bk_addPageCtx("q_" + varName, urlParams[varName]);
			}
		}
	}

	// PLUG-IN : Query-String Stripper
	_bk.f.strip_query_string_params = function() {
		if (_bk.conf.strip_query_string_params && !_bk.conf.block_all_meta) {

			_bk.conf.block_all_meta = true;
			_bk.f.block_all_meta();

			var url = document.location.protocol + "//" + document.domain + document.location.pathname;
			bk_addPageCtx('__bk_l', url);
			bk_addPageCtx('__bk_r', document.referrer.split("?")[0]);
			if (_bk.conf.send_multi_url_path) {
				bk_addPageCtx('ex_url', url);
				bk_addPageCtx('ex_path', document.location.pathname);
				bk_addPageCtx('ex_path2', document.location.pathname);
			}
		}
	}
	// Run functions
	_bk.f.block_all_meta();
	_bk.f.multi_call();
	_bk.f.send_multi_url_path();
	_bk.f.declare_query_string_params();
	_bk.f.strip_query_string_params();

	// Send Data 
	BKTAG.doTag(_bk.conf.container_id, _bk.conf.auction_limit);

};
(function() {
	var scripts = document.getElementsByTagName('script')[0];
	var s = document.createElement('script');
	s.async = true;
	s.src = "https://tags.bkrtx.com/js/bk-coretag.js";
	scripts.parentNode.insertBefore(s, scripts);
}());
</script>
<!-- End BlueKai Tag -->