Voice of Customer API (advanced customization)

From wiki.usabilitytools.com
Jump to: navigation, search

This is the description for Application Programming Interface of UsabilityTools Feedback Form tool. It is aimed at programmers - your IT department after reading this page will know how to customize the Feedback Form behavior to your website's needs.


If you want to use Feedback Form on your site, but you want to provide feedback button by yourself, or even if you want to display form on some action other than clicking button, you can use our API to interact with Feedback Form script.

To disable default feedback button, add the following line to the standard tracking script code:

 window.UTC_FF= { custom: true };

Feedback Form API contains five public methods at the moment:

 window.UTC_FF.showForm()

Recommended. Displays Feedback Form on your site using best available method of user's browser (div overlay or popup window). Unless, for some reason, you don't want Feedback Form script to add any elements dynamically to your page, or you explicitly don't want to support older browsers, you should use only this method to display Feedback Form.

 window.UTC_FF.showOverlay()

Displays Feedback Form on your site, always using div overlay with fixed positioning. Requires cross-domain requests support on user's browser.

 window.UTC_FF.showPopup()

Displays Feedback Form on your site, always using popup window.

 window.UTC_FF.showPrompt([interval])

Displays prompt (specified in Design tab) near feedback button. When default button is disabled, this method does nothing. Optional argument interval specifies in miliseconds how long should the prompt be visible. Set it to 0 if you want to disable automatic hiding.

 window.UTC_FF.hidePrompt()

Hides feedback prompt. When default button is disabled, this method does nothing.

IMPORTANT: API functions won't be available when project is stopped, either explicitly by you, or automatically due to stop conditions or lack of credits on your account. Also, keep in mind that Feedback Form script is loaded asynchronously. This means that API may not be available instantly on the page load. To avoid exceptions in such cases, you should always test if your project is available before making API call. For example:

 if ((window.UTC_FF) && (window.UTC_FF.showForm)) {
   window.UTC_FF.showForm();
 } else {
   // feedback form not available, fallback
 }

You can also use script version with load callback.

 (function(s,o,c,g,l,a,m){a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.defer=1;a.charset=c;a.onload=l;a.src=g;m.parentNode.insertBefore(a,m)})
 (document,'script','utf-8','https://usabilitytools.com/ff/rest/script/YOUR_PROJECT_ID_HERE',function() {
   // script loaded
   // put all API calls here
 });