Surveys
Similar to Widgets, you can access any Survey loaded by the Frill Script. Using the Frill API is simple once you have a reference to a Survey. To do this, you first need to know the Key, which you can find in your Survey dashboard, or on the edit screen.
Please read the manual loading documentation for Widgets for instructions on how to disable automatic loading of all Surveys in the Frill Script.
Frill('survey')
Frill('survey')
The easiest way to get access to a Survey is by calling the survey
command with the Survey Key. If the Survey is already loaded, the function will return the existing instance, making it safe to call multiple times.
Using the survey
command to load a Survey will ignore all targeting rules (e.g. URL matching).
const survey = await window.Frill('survey', {
key: 'YOUR_SURVEY_KEY', // <-- Add Survey key here
callbacks: {
onReady(survey) {
console.log(survey);
},
},
});
Using container onReady
callback
onReady
callbackAnother option is to providing an onReady
callback in your script configuration. This callback will run once when ready and will receive the Survey instance.
window.Frill('container', {
key: 'YOUR_CONTAINER_KEY',
surveys: [
{
key: 'YOUR_SURVEY_KEY', // <-- Add Survey key here
callbacks: {
onReady(survey) {
// This function is called when the Frill Survey is fully loaded and ready for use
console.log(survey);
},
},
},
]
});
Last updated