Skip to main content
Users
CloudPortalLogin
  • Powered byPowered by
Developing with Sitecore CDP
Data privacy
Before you start sending data
Integrating with Sitecore CDP
Stream API
Batch API
REST APIs
Data lake export service
  • Sitecore CDP for developers
  • Stream API
  • Sitecore Engage SDK reference
  • Functions
  • Engage.clearEventQueue()

Engage.clearEventQueue()

The clearEventQueue() function empties the event queue, removing all the events that are in it, without sending any of the events.

sidebar. Parameters

none

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();
  };
};

Do you have some feedback for us?

If you have suggestions for improving this article,

Privacy policySitecore Trust CenterCopyright © 1999-2026 Sitecore