---
title: "Engage.addToEventQueue(type, eventData[, extensionData])"
slug: "engage-addtoeventqueue"
abstract: "Describes the addToEventQueue() function in the Sitecore Engage SDK (Sitecore CDP Stream API)."
---
# Engage.addToEventQueue(type, eventData\[, extensionData\])

The `addToEventQueue()` function saves any event with a valid payload to the event queue. After you call this function, you can run the event queue using `processEventQueue()` or empty it using `clearEventQueue()`.

sidebar. Parameters

This function accepts the same parameters as the [`event()`](https://doc.sitecore.com/cdp/en/developers/api/stream-api/sitecore-engage-sdk-reference/functions/engage-event.html "Engage.event(type, eventData[, extensionData])") function. It supports both standard and custom events.

Here's an example of how to use the `addToEventQueue` function to save events to 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.

In the following order, either the `DROPDOWN_CLICK` then the `DROPDOWN_ITEM_CLICK` events are added to the event queue, or the `DROPDOWN_CLICK` then the `DROPDOWN_ABANDON` events are added.

```javascript
if (clickedDropdown) {
  engage.addToEventQueue("DROPDOWN_CLICK", eventData);

  if (clickedDropdownItem) {
    engage.addToEventQueue("DROPDOWN_ITEM_CLICK", eventData);
  } else {
    engage.addToEventQueue("DROPDOWN_ABANDON", eventData);
  };

  engage.processEventQueue();
};

```