setDispatchInterval

The setDispatchInterval() method sets a custom dispatch interval time. Tracked events are temporarily stored in a queue and dispatched in batches. The default dispatch interval time is 30 seconds (3000 milliseconds) – batches are sent every 30 seconds.

Syntax

getTracker().setDispatchInterval(milliseconds)
tracker.dispatchInterval = milliseconds

Parameters

milliseconds (number, required)

The interval time (in milliseconds) for dispatching tracked events. If 0 milliseconds, events will be sent right away. If -1 milliseconds, events won’t be sent automatically and can be send manually.

Examples

To set the dispatch interval time to 60 seconds (60x1000 milliseconds):

getTracker().setDispatchInterval(60 * 1000)
tracker.dispatchInterval = 60 * 1000

To block sending events automatically and send them manually:

Tracker tracker = ((MyApplication) getApplication()).getTracker(); tracker.setDispatchInterval(-1); // Catch and track exception try { cartItems = getCartItems(); } catch (Exception e) { TrackHelper.track().exception(e).description(e.getMessage()); tracker.dispatch(); cartItems = null; }
val tracker: Tracker = (application as PiwikApplication).getTracker() tracker.dispatchInterval = -1 // Catch and track exception try { cartItems = tracker.getCartItems() } catch (e: java.lang.Exception) { TrackHelper.track().exception(e).description(e.message) tracker.dispatch() cartItems = null }

Notes

  • If more than one event is queued, the data is sent in bulk using the POST method with a JSON payload.

Did this page help you?