Synchronous methods and hooks

Overview

The Vue SDK presents several methods and hooks that can be used for attaching additional behavior. Here is a list of them with a short sample on how to use them.

 

Track method

Each widget created via the HawksearchVue.createWidget() has an instance of the track event object. Every triggered tracking event is passed through the object’s track method. This usually happens asynchronously but in some cases, a set of actions must be executed exclusively after the tracking has been registered. For instance, clicking on a result item triggers a tracking event and opens the details page.

if (this.trackEvent) { this.trackEvent.track('click', { event: e, uniqueId: this.result.DocId, trackingId: this.getResponseField('TrackingId'), url: link }); } location.assign(link);

Implementing the redirect to be immediately after the tracking method will result in the following modification:

if (this.trackEvent) { this.trackEvent.track('click', { event: e, uniqueId: this.result.DocId, trackingId: this.getResponseField('TrackingId'), url: link }).then(() => { location.assign(link); }) }

In essence - the track method returns a Promise which resolves at successful tracking event triggering.

Â