Survey Events
Which survey events can I listen for?
All six SenseFolks survey components emit sfError. FastPoll, OpenFeedback, PricePoint, and Reaction also emit sfReady and sfSubmit.
| Event | When it fires | Components |
|---|---|---|
sfError | Load, submission, or validation failure | All six survey types |
sfReady | Survey initialisation completes | FastPoll, OpenFeedback, PricePoint, Reaction |
sfSubmit | A response is submitted | FastPoll, OpenFeedback, PricePoint, Reaction |
UserChoice and FeaturePriority do not emit ready or submit events. Check each component reference for event details and additional interaction events.
How do I attach an event listener?
Attach listeners to the mounted survey element. Event names are case-sensitive.
const survey = document.querySelector('sf-fastpoll');
const onSubmit = ({ detail }) => console.log('Submitted:', detail);
const onError = ({ detail }) => console.error(detail.errorMessage);
survey?.addEventListener('sfSubmit', onSubmit);
survey?.addEventListener('sfError', onError);
// Remove listeners when the view unmounts.
function cleanup() {
survey?.removeEventListener('sfSubmit', onSubmit);
survey?.removeEventListener('sfError', onError);
}React
useEffect(() => {
const survey = ref.current;
if (!survey) return;
const onSubmit = ({ detail }) => track('survey_submit', detail);
survey.addEventListener('sfSubmit', onSubmit);
return () => survey.removeEventListener('sfSubmit', onSubmit);
}, []);Use browser events for analytics and interface updates. Verify server-side actions independently.
Why is my event listener not firing?
- Check that your component supports the event.
- Use the exact event name, such as
sfSubmit. - Attach the listener before the interaction occurs.
- For FastPoll and OpenFeedback, keep
enableEventsenabled.
See event troubleshooting, the embedding tutorial, and the web components reference.