IBM Support

Scheduling Future Events

Question & Answer


Question

Scheduling Future Events

Answer

Sometimes it is more useful to trigger an event at a known time in the future than to trigger one immediately. Example use cases include following up on an item that has been placed in the shopping cart several minutes later or offering a coupon after a certain time period following session start. Several methods are provided to facilitate these use cases.

Due to the nature of the browser environment, it is only possible to trigger an event when the user has a tab or window with your website open. As such, if an event is scheduled for the future but no tab is available at the scheduled date/time, the event cannot be triggered. In light of this, an optional expiration date may be provided when scheduling your event. If the user returns to your page after the event was scheduled to fire but before the expiration date, the event will be triggered. If they return to your site after the scheduled time and also after the expiration date, the event will never be triggered.

One event of a given name may be scheduled at any time. Only the most recently scheduled event for any given event name (?ITEM_ADDED_TO_CART?) will be honored.

Scheduling an Event for an Absolute Date

In order to trigger a given event at a known date/time, use the scheduleEvent method.

var eventName = 'CART_ITEM_ADDED_FOLLOWUP';var eventAction = 'sku#1234';var triggerDate = new Date(2013-05-28T16:04:00-0400");var expirationDate = new Date("2013-06-28T16:04:00-0400"); // OptionalReactor.Scheduler.scheduleEvent(eventName eventAction triggerDate expirationDate);

Scheduling a Delayed Event

In order to trigger a given event after a period of time has passed (rather than at a given date/time) use the scheduleDelayedEvent method. Unlike the scheduleEvent method above the optional expiration parameter for scheduling a delayed event is a timeToLive expressed in milliseconds.

var eventName = 'CART_ITEM_ADDED_FOLLOWUP';
var eventAction = 'sku#1234';
var triggerDelay = 30 * 1000; // In 30 seconds
var timeToLive = 10 * 1000; // Optional. The message has a time to live of 10 seconds after the trigger.
Reactor.Scheduler.scheduleDelayedEvent(eventName eventAction triggerDelay timeToLive);

Unscheduling a Scheduled Event

In order to prevent a scheduled event from firing use the unscheduleEvent method.

var eventName = 'CART_ITEM_ADDED_FOLLOWUP';
Reactor.Scheduler.unscheduleEvent(eventName);

ntName);

"

[{"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Product":{"code":"SSMRUB","label":"IBM Mobile Web Push"},"Component":"","Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"All Versions","Edition":"","Line of Business":{"code":"","label":""}}]

Document Information

Modified date:
08 December 2018

UID

ibm10772503