dispatch

The dispatch() method sends queued analytics events to the tracker.

If the queue contains more events than the value configured in eventsPerRequest, the SDK sends them in multiple HTTP requests. Each request contains up to the configured number of events.

When optOut is enabled, the SDK does not store new events. However, dispatch() can still send events that were queued before opt-out was enabled.

To delete those queued events without sending them, use deleteQueuedEvents().

Syntax

PiwikTracker.sharedInstance()?.dispatch()
[[PiwikTracker sharedInstance] dispatch];

Examples

To disable automatic dispatching, do the following:

PiwikTracker.sharedInstance()?.dispatchInterval = -1

PiwikTracker.sharedInstance()?.sendEvent(
    category: "Clicks",
    action: "Button",
    name: "Sign up",
    value: 100,
    path: "/main/signup"
)

PiwikTracker.sharedInstance()?.dispatch()
[PiwikTracker sharedInstance].dispatchInterval = -1;

[[PiwikTracker sharedInstance] sendEventWithCategory:@"Clicks"
                                              action:@"Button"
                                                name:@"Sign up"
                                               value:@100
                                                path:@"/main/signup"];

[[PiwikTracker sharedInstance] dispatch];

Notes

  • dispatchInterval controls how often the SDK automatically calls dispatch() (default: 30 s). Set it to -1 to send events only through manual dispatch() calls.
  • eventsPerRequest limits the number of queued analytics events sent in a single HTTP request. If more events are queued, a single dispatch() call sends multiple requests (see above).
  • maxNumberOfQueuedEvents limits the number of events the SDK can store in local storage. When the limit is reached, new events may be dropped until previously queued events are sent successfully.

Related methods


Did this page help you?