Skip to main content

Dispatch

The Uniform tracker allows you to hook into the dispatch process so you can apply your own dispatch logic.

Add event handler to front-end#

When the dispatch process runs, the Uniform tracker triggers an event. You can add an event handler to the tracker in order to run custom code.

The event handler must match the signature of DispatchEventHandler. The way you implement the event handler depends on the type of front-end and your coding preference.

JSS sites (React)#

In order to add an event handler for the dispatch event, the prop onDispatch must be set on the hook used to configure the tracker.

const handler = (result, settings, logger) => {     //do something };
useSitecoreTracker(sitecoreContext, {    type: "jss",    onDispatch: handler});

MVC sites#

In order to add an event handler for the dispatch event, the setting OnDispatch must be set on the HTML helper used to configure the tracker.

<script>    function handler(result, settings, logger) {        // do something    }</script>
@Html.Uniform().TrackerWith(settings => {    settings.OnDispatch = "handler";})