Queueing events

Current version: 0.3

When using client-side tracking, 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 in the EventQueue key. You can add any event that supports the event queue and has a valid payload to the event queue.

Important

The event queue requires that session storage is enabled. Because site visitors can disable session storage, you should use try-catch blocks to handle errors when you're interacting with the event queue.

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

  • addToEventQueue - to add event objects with a valid payload to the event queue.

  • processEventQueue - to send all the events in the event queue, in the order the events were added. Then, this function empties the event queue.

  • clearEventQueue - to empty the event queue without sending any of the events.

Do you have some feedback for us?

If you have suggestions for improving this article,