Skip to main content
Version: Vue SDK

Start survey programmatically

Manually trigger a survey by its ID.

<script setup lang="ts">
import { useScreeb } from "@screeb/sdk-vue";

const { surveyStart } = useScreeb();

async function showSurvey() {
await surveyStart(
"<survey-id>",
"<distribution-id>",
false,
{ // optional hidden fields
color: "green",
article_id: 42,
},
{ // optional hooks
version: "1.0.0",
onSurveyShowed: (payload) => console.log("Survey showed", payload),
},
"en", // optional language
"#screeb-survey-container" // optional CSS selector for the container
);
}
</script>

<template>
<button @click="showSurvey">Show survey</button>
</template>

Parameters:

ParameterTypeRequiredDescription
surveyIdstringYesThe survey UUID from your Screeb workspace
distributionIdstringNoDistribution channel ID
allowMultipleResponsesbooleanNoAllow the survey to be shown multiple times (default: false)
hiddenFieldsPropertyRecordNoHidden fields to pass to the survey
hooksHooksSurveyStartNoCallback hooks for survey events
languagestringNoForce a specific language (e.g. "en", "fr")
selectorsstring | string[]NoCSS selector(s) for custom container

Close survey

Close the currently running survey:

<script setup lang="ts">
import { useScreeb } from "@screeb/sdk-vue";

const { surveyClose } = useScreeb();
</script>

<template>
<button @click="surveyClose">Close survey</button>
</template>