Skip to content

JavaScript API

When the standard embed button codes or placeholder codes do not suit your needs, but you want to embed your project into your website, you could use the JavaScript API.

Note: This method will require you to have a basic understanding of JavaScript.

To use the JS API, you can embed the same script tag, which is used for the standard embed elements. This is found on the launch page of your survey.

Directly making calls to the API, immediately after load, could fail if the script is not yet ready. If your calls to the API are made on the page load it is recommended that they are placed inside the ready handler.

ShoutEmbed.ready(function(){ // Make calls to API here });

There are three types of embed, for each of these there is a different function call on the API. When this is called, it will create the embed, it will also return an instance of the EmbedController which will allow you to communicate with the instance of this form later.

First, we will look at the different calls which can be made, then at the parameters which can be supplied.   ShoutEmbed.api.popout({ formId: "###" }); ShoutEmbed.api.slideout({ formId: "###" }); ShoutEmbed.api.inline({ formId: "###", appendTo: "survey-placeholder" });

Making calls to these functions alone will not work. We need to supply an object defining what we want it to do.

ParameterTypeDescriptionPopoutSlideoutInline
formIdStringDefines which form we want to embed into the page. You can find this on the launch page, it is the end of the launch URL.RequiredRequiredRequired
closeOnCompleteBooleanCloses the form on completion, any thank you page will not be displayed. Default: TRUE (pass false to keep it open)xx
appendToString or ElementElement the form is to be appended to on creation. This can be the element id or the element object. Default: BODYxxRequired
initialColorStringAccepts a Hex color code. Used to define the color of the element which appears before the form has loaded. Default: #5E5E5Exx
directionStringWhich side of the page a slideout should appear on. Can be “left” or “right”. Default: “right”x
onFormLoadedFunctionCalled when the form is open and loaded.xxx
onNextPageFunctionCalled when the user navigates to the next page within the form.xxx
onPreviousPageFunctionCalled when the user navigates to the previous page within the form.xxx
onCompleteFunctionCalled when the user completes the form.xxx
onValidationFunctionCalled when the form enters the validation state.xxx
onUserClosedFormFunctionCalled when the user closes the form before it is completed.xx
customObjectObject containing custom user defined strings. Read more about text piping.xxx