As a developer I try to integrate Sitecore CDP API what ends up with sending many duplicated requests in very short time. Some of them are user related and I need to reset the session to test the user paths correctly. To do it faster I would like to end the user session on the Sitecore CDP side on demand without waiting until CDP ends it. Is it possible to send a request that will finish the session on CDP side?
1 Answer
Yes, it is possible to finish the session on demand. To achieve it, you must send request looking like this one:
_boxeverq.push(function(){
var viewEvent = {
"type" : "FORCE_CLOSE",
"browser_id" : _boxever.getID(),
"channel" : "WEB",
"page" : window.location.href,
"pos" : "Sygnity",
"_bx_extended_message" : "1"
};
_boxever.eventCreate(viewEvent, function(data){},"json");
});
The crucial thing here is the type : FORCE_CLOSE
-
2It is important to note, the
FORCE_CLOSE
event it not completely supported in the production environments, it is not as reliable as the timeout for the session end, especially in higher volumes. It is best to use this for demo and PoC work only.– Richard Seal ♦Commented Feb 15, 2022 at 16:57