Engage.clearEventQueue()
The clearEventQueue()
function empties the event queue, removing all the events that are in it, without sending any of the events.
Here's an example of how to use the clearEventQueue
function to empty the event queue.
In this scenario, we add different events to the event queue depending on whether a site visitor clicked a dropdown menu and a dropdown menu item.
If a certain condition is met, you decide to empty the event queue and not send any of the events you previously added to it.
RequestResponse
if (clickedDropdown) {
engage.addToEventQueue("DROPDOWN_CLICK", eventData);
if (clickedDropdownItem) {
engage.addToEventQueue("DROPDOWN_ITEM_CLICK", eventData);
} else {
engage.addToEventQueue("DROPDOWN_ABANDON", eventData);
};
if (timeout) {
engage.clearEventQueue();
};
};