Two code snippets - one to implement in BK and the other to implement on the page to make BKUUID available to Walmeric
/*
######################
### BKUUID GRABBER ###
######################
Author : roshan.gonsalkorale@oracle.com
Pre-requisites:
- https://gist.github.com/roshanbluekai/6c0b93f03b92ddcfeb33445739228e78#file-bkkuid_expose-html to be implemented in BlueKai
Instructions :
- This code must fire BEFORE the BlueKai CoreTag code snippet
- Will work in Tag Managers or directly on site
*/
// Declare Global Object
window.bluekai_service = window.bluekai_service || {};
window.bluekai_service.functions = window.bluekai_service.functions || {};
window.bluekai_service.bkuuid_caller = window.bluekai_service.bkuuid_caller || {};
// ### FUNCTIONS ###
// FUNCTION : BKUUID Parent Receiver
bluekai_service.functions.walmericBkuuidParentReceiver = function(event) {
if (event.origin.indexOf("tags.bluekai.com") > -1) {
if (window.bluekai_service.bkuuid_caller.__bluekai_data_sent === false && typeof event.data !== 'undefined' && event.data.source === 'bluekai') {
window.walmericBkuuid = event.data.walmericBkuuids.bk_uuid;
window.walmericBkuuidNoSlash = event.data.walmericBkuuids.bk_uuid_noslash;
window.bluekai_service.bkuuid_caller.__bluekai_data_sent = true;
}
}
}
// ### EXECUTION ###
window.bluekai_service.bkuuid_caller.__bluekai_data_sent = false;
addEventListener('message', window.bluekai_service.functions.walmericBkuuidParentReceiver, false);
<!-- CODE BELOW TO BE RUN IN BLUEKAI TAG MANAGEMENT -->
<script type="text/javascript">
var bk_uuids = {
"bk_uuid":"$_BK_UUID",
"bk_uuid_noslash":"$_BK_UUID_NOSLASH"
};
parent.postMessage({walmericBkuuids: bk_uuids, source: 'bluekai' }, '*');
</script>