---
title: "The event queue"
slug: "the-event-queue"
abstract: "Queue multiple events in session storage before sending them to Sitecore in one go using the Cloud SDK."
---
# The event queue

When using [client-side tracking](https://doc.sitecore.com/sdk/en/developers/005/cloud-sdk/cloud-sdk-concepts/concepts-tracking/events.html#UUID-b78ff86e-4442-71e7-edc6-81adf8fabe27_section-idm1903449501184294 "Options for sending events"), instead of sending events one by one, you can first collect events into a queue, then send them later in one go. This is useful when, for example, you want to conditionally chain different events depending on which actions your site visitor performs.

To collect events, you can use the event queue. The event queue is a first-in, first-out array stored in [session storage](https://developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage) in the `EventQueue` key. You can add any event that [supports the event queue](https://doc.sitecore.com/sdk/en/developers/005/cloud-sdk/cloud-sdk-concepts/concepts-tracking/events.html#UUID-b78ff86e-4442-71e7-edc6-81adf8fabe27_section-idm4572049061448034050984431341 "Overview of events") and has a valid payload.

> [!important]
> The event queue requires that session storage is enabled. Because site visitors can disable session storage, you should use try-catch blocks when you're setting up the event queue.

To interact with the event queue, you can use the following asynchronous functions:

- [`addToEventQueue`](https://doc.sitecore.com/sdk/en/developers/005/cloud-sdk/cloud-sdk-reference/cloud-sdk-events/cloud-sdk-events-browser/functions/cloud-sdk-events-browser-addtoeventqueue.html "addToEventQueue") - adds an event object with a valid payload to the event queue.
- [`processEventQueue`](https://doc.sitecore.com/sdk/en/developers/005/cloud-sdk/cloud-sdk-reference/cloud-sdk-events/cloud-sdk-events-browser/functions/cloud-sdk-events-browser-processeventqueue.html "processEventQueue") - sends all the events in the event queue, in the order they were added. Afterwards, this function empties the event queue.
- [`clearEventQueue`](https://doc.sitecore.com/sdk/en/developers/005/cloud-sdk/cloud-sdk-reference/cloud-sdk-events/cloud-sdk-events-browser/functions/cloud-sdk-events-browser-cleareventqueue.html "clearEventQueue") - empties the event queue without sending any of the events.