/
Synchronous methods and hooks

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.

 

Related content

Track Event URL
Track Event URL
More like this
Widget Guid
Widget Guid
More like this
Example: Extending result item component to include a field from the response object
Example: Extending result item component to include a field from the response object
More like this
Synchronized widgets
Synchronized widgets
More like this
Creating widgets with Vue SDK
Creating widgets with Vue SDK
More like this
Extending the Vuex store
Extending the Vuex store
More like this