In this article, we will focus on event callbacks. We will talk about what they are, how you can combine them with our products and give a couple of examples of use cases.
Event callbacks: what are they?
How can I combine them with Usabilla?
The callback above is just a simple one, but in essence, this is what an event callback does.
So how does Usabilla use them? We use a number of callbacks (see below) to signal that an interaction with Usabilla has taken place on a website. You could then send information from Usabilla to other web optimization tools, such as analytics tools, A/B testing tools or Data Management Platforms.
This function will be called when one of the below events occur on your website. For each event the function's parameters will be used as described.
Please note that 'setEventCallback' can only be defined once on every page and that it must always be defined after the default Usabilla script has been loaded. If you try to define it more than once on a page, the callback function will be overwritten with the last defined one.
This event is fired when the user clicks on your feedback button to open the feedback form. It uses the following arguments in the callback function.
This event is fired when the user successfully completes the feedback form. It uses the following arguments in the callback function.
label: The comment the user entered.
value: The mood rating score given by the user (1 - 5).
userData: An object containing the responses the user provided.
This event is fired when an active campaign is shown to the user. It uses the following arguments in the callback function.
This event is fired when the user clicks the continue button in a campaign to navigate to the next page of this campaign. It uses the following arguments in the callback function.
userData: An object containing the responses the user provided. The user's responses will be nested into another object called "data".
This event is fired when the user submits their campaign responses on the last page of the campaign, clicks the redirect button of a Recruit Participants survey or when the user provides feedback, while a Boost live feedback campaign is active. It uses the following arguments in the callback function.
This event is fired when the user closes a campaign by clicking its exit cross or the optional "close" link. It uses the following arguments in the callback function.
This event is fired in addition to the "Feedback:Open" event when the user clicks the call to action button in a Boost live Feedback campaign. It uses the following arguments in the callback function.
- Push events to your analytics suite, including the feedback a user left.
- Push events to your A/B test tool, including the user's feedback on a test variant.
- Push events to your CRM tool, in order to add feedback to their profile.
- Trigger a chat functionality for unhappy users to provide further assistance.
- Trigger a Usabilla survey in the current or a future visit to follow up on the user's feedback.
Define the event callback function.
Since some of the responses are in nested objects, we create a function to flatten arrays.
We then check whether the user is taking the desired action; leaving a feedback item or campaign response.
Lastly, we log each question value and user response to the console.
Hopefully, this article will get you started. We look forward to seeing your usage of our event callbacks live in action. Any questions? Please reach out to our support team.